Browse Source

Update grunt/ratchicons-data-generator.js to the latest upstream version.

pull/771/head
XhmikosR 10 years ago
parent
commit
d7fa4b7b5f
  1. 2
      Gruntfile.js
  2. 11
      grunt/ratchicons-data-generator.js

2
Gruntfile.js

@ -401,7 +401,7 @@ module.exports = function (grunt) {
grunt.registerTask('server', ['dist', 'jekyll:docs', 'connect', 'watch']);
grunt.registerTask('prep-release', ['dist', 'jekyll:github', 'htmlmin', 'compress']);
grunt.registerTask('build-ratchicons-data', generateRatchiconsData);
grunt.registerTask('build-ratchicons-data', function () { generateRatchiconsData.call(this, grunt); });
// Version numbering task.
// grunt change-version-number --oldver=A.B.C --newver=X.Y.Z

11
grunt/ratchicons-data-generator.js

@ -8,9 +8,10 @@
/* jshint node: true */
'use strict';
var fs = require('fs');
module.exports = function generateRatchiconsData() {
module.exports = function generateRatchiconsData(grunt) {
// Pass encoding, utf8, so `readFileSync` will return a string instead of a
// buffer
var ratchiconsFile = fs.readFileSync('sass/ratchicons.scss', 'utf8');
@ -20,6 +21,7 @@ module.exports = function generateRatchiconsData() {
var iconClassName = /^\.(icon-[^\s]+)/;
var ratchiconsData = '# This file is generated via Grunt task. **Do not edit directly.**\n' +
'# See the \'build-ratchicons-data\' task in Gruntfile.js.\n\n';
var ratchiconsYml = 'docs/_data/ratchicons.yml';
for (var i = 0, len = ratchiconsLines.length; i < len; i++) {
var match = ratchiconsLines[i].match(iconClassName);
@ -33,5 +35,10 @@ module.exports = function generateRatchiconsData() {
fs.mkdirSync('docs/_data');
}
fs.writeFileSync('docs/_data/ratchicons.yml', ratchiconsData);
try {
fs.writeFileSync(ratchiconsYml, ratchiconsData);
} catch (err) {
grunt.fail.warn(err);
}
grunt.log.writeln('File ' + ratchiconsYml.cyan + ' created.');
};

Loading…
Cancel
Save