Permalink
Browse files

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

…ion.
  • Loading branch information...
1 parent a722ffc commit d7fa4b7b5fe3a730cc53a390262a5fbaa8bb79a8 @XhmikosR XhmikosR committed Apr 30, 2015
Showing with 10 additions and 3 deletions.
  1. +1 −1 Gruntfile.js
  2. +9 −2 grunt/ratchicons-data-generator.js
View
@@ -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
@@ -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.');
};

0 comments on commit d7fa4b7

Please sign in to comment.