From 5cec523755a3f6d4e22c3ebb32d96ee1f1d24262 Mon Sep 17 00:00:00 2001 From: Eric Ferraiuolo Date: Mon, 18 Nov 2013 14:45:37 -0500 Subject: [PATCH] Move local Grunt tasks to tasks/ dir --- Gruntfile.js | 63 ++++-------------------------------------- tasks/bower_install.js | 21 ++++++++++++++ tasks/license.js | 18 ++++++++++++ tasks/suppress.js | 21 ++++++++++++++ 4 files changed, 65 insertions(+), 58 deletions(-) create mode 100644 tasks/bower_install.js create mode 100644 tasks/license.js create mode 100644 tasks/suppress.js diff --git a/Gruntfile.js b/Gruntfile.js index e0ab3bf..495fd66 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -213,6 +213,7 @@ grunt.initConfig({ // -- Main Tasks --------------------------------------------------------------- +// npm tasks. grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-concat'); @@ -222,8 +223,11 @@ grunt.loadNpmTasks('grunt-contrib-compress'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-css-selectors'); +// Local tasks. +grunt.loadTasks('tasks/'); + grunt.registerTask('default', ['import', 'test', 'build']); -grunt.registerTask('import', ['bower-install']); +grunt.registerTask('import', ['bower_install']); grunt.registerTask('test', ['csslint']); grunt.registerTask('build', [ 'clean:build', @@ -245,61 +249,4 @@ grunt.registerTask('release', [ 'compress:release' ]); -// -- Suppress Task ------------------------------------------------------------ - -grunt.registerTask('suppress', function () { - var allowed = ['success', 'fail', 'warn', 'error']; - - grunt.util.hooker.hook(grunt.log, { - passName: true, - - pre: function (name) { - if (allowed.indexOf(name) === -1) { - grunt.log.muted = true; - } - }, - - post: function () { - grunt.log.muted = false; - } - }); -}); - -// -- Bower Tasks -------------------------------------------------------------- - -grunt.registerTask('bower-install', 'Installs Bower dependencies.', function () { - var bower = require('bower'), - done = this.async(); - - bower.commands.install() - .on('log', function (data) { - if (data.id !== 'install') { return; } - grunt.log.writeln('bower ' + data.id.cyan + ' ' + data.message); - }) - .on('end', function (results) { - if (!Object.keys(results).length) { - grunt.log.writeln('No bower packages to install.'); - } - - done(); - }); -}); - -// -- License Task ------------------------------------------------------------- - -grunt.registerMultiTask('license', 'Stamps license banners on files.', function () { - var options = this.options({banner: ''}), - banner = grunt.template.process(options.banner), - tally = 0; - - this.files.forEach(function (filePair) { - filePair.src.forEach(function (file) { - grunt.file.write(file, banner + grunt.file.read(file)); - tally += 1; - }); - }); - - grunt.log.writeln('Stamped license on ' + String(tally).cyan + ' files.'); -}); - }; diff --git a/tasks/bower_install.js b/tasks/bower_install.js new file mode 100644 index 0000000..97ab5c3 --- /dev/null +++ b/tasks/bower_install.js @@ -0,0 +1,21 @@ +'use strict'; + +module.exports = function (grunt) { + grunt.registerTask('bower_install', 'Installs Bower dependencies.', function () { + var bower = require('bower'), + done = this.async(); + + bower.commands.install() + .on('log', function (data) { + if (data.id !== 'install') { return; } + grunt.log.writeln('bower ' + data.id.cyan + ' ' + data.message); + }) + .on('end', function (results) { + if (!Object.keys(results).length) { + grunt.log.writeln('No bower packages to install.'); + } + + done(); + }); + }); +}; diff --git a/tasks/license.js b/tasks/license.js new file mode 100644 index 0000000..8564cc9 --- /dev/null +++ b/tasks/license.js @@ -0,0 +1,18 @@ +'use strict'; + +module.exports = function (grunt) { + grunt.registerMultiTask('license', 'Stamps license banners on files.', function () { + var options = this.options({banner: ''}), + banner = grunt.template.process(options.banner), + tally = 0; + + this.files.forEach(function (filePair) { + filePair.src.forEach(function (file) { + grunt.file.write(file, banner + grunt.file.read(file)); + tally += 1; + }); + }); + + grunt.log.writeln('Stamped license on ' + String(tally).cyan + ' files.'); + }); +}; diff --git a/tasks/suppress.js b/tasks/suppress.js new file mode 100644 index 0000000..46602c6 --- /dev/null +++ b/tasks/suppress.js @@ -0,0 +1,21 @@ +'use strict'; + +module.exports = function (grunt) { + grunt.registerTask('suppress', 'Suppresses noisy logs', function () { + var allowed = ['success', 'fail', 'warn', 'error']; + + grunt.util.hooker.hook(grunt.log, { + passName: true, + + pre: function (name) { + if (allowed.indexOf(name) === -1) { + grunt.log.muted = true; + } + }, + + post: function () { + grunt.log.muted = false; + } + }); + }); +};