Skip to content

Commit 5cec523

Browse files
committed
Move local Grunt tasks to tasks/ dir
1 parent bdc76d6 commit 5cec523

File tree

4 files changed

+65
-58
lines changed

4 files changed

+65
-58
lines changed

Gruntfile.js

Lines changed: 5 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ grunt.initConfig({
213213

214214
// -- Main Tasks ---------------------------------------------------------------
215215

216+
// npm tasks.
216217
grunt.loadNpmTasks('grunt-contrib-clean');
217218
grunt.loadNpmTasks('grunt-contrib-copy');
218219
grunt.loadNpmTasks('grunt-contrib-concat');
@@ -222,8 +223,11 @@ grunt.loadNpmTasks('grunt-contrib-compress');
222223
grunt.loadNpmTasks('grunt-contrib-watch');
223224
grunt.loadNpmTasks('grunt-css-selectors');
224225

226+
// Local tasks.
227+
grunt.loadTasks('tasks/');
228+
225229
grunt.registerTask('default', ['import', 'test', 'build']);
226-
grunt.registerTask('import', ['bower-install']);
230+
grunt.registerTask('import', ['bower_install']);
227231
grunt.registerTask('test', ['csslint']);
228232
grunt.registerTask('build', [
229233
'clean:build',
@@ -245,61 +249,4 @@ grunt.registerTask('release', [
245249
'compress:release'
246250
]);
247251

248-
// -- Suppress Task ------------------------------------------------------------
249-
250-
grunt.registerTask('suppress', function () {
251-
var allowed = ['success', 'fail', 'warn', 'error'];
252-
253-
grunt.util.hooker.hook(grunt.log, {
254-
passName: true,
255-
256-
pre: function (name) {
257-
if (allowed.indexOf(name) === -1) {
258-
grunt.log.muted = true;
259-
}
260-
},
261-
262-
post: function () {
263-
grunt.log.muted = false;
264-
}
265-
});
266-
});
267-
268-
// -- Bower Tasks --------------------------------------------------------------
269-
270-
grunt.registerTask('bower-install', 'Installs Bower dependencies.', function () {
271-
var bower = require('bower'),
272-
done = this.async();
273-
274-
bower.commands.install()
275-
.on('log', function (data) {
276-
if (data.id !== 'install') { return; }
277-
grunt.log.writeln('bower ' + data.id.cyan + ' ' + data.message);
278-
})
279-
.on('end', function (results) {
280-
if (!Object.keys(results).length) {
281-
grunt.log.writeln('No bower packages to install.');
282-
}
283-
284-
done();
285-
});
286-
});
287-
288-
// -- License Task -------------------------------------------------------------
289-
290-
grunt.registerMultiTask('license', 'Stamps license banners on files.', function () {
291-
var options = this.options({banner: ''}),
292-
banner = grunt.template.process(options.banner),
293-
tally = 0;
294-
295-
this.files.forEach(function (filePair) {
296-
filePair.src.forEach(function (file) {
297-
grunt.file.write(file, banner + grunt.file.read(file));
298-
tally += 1;
299-
});
300-
});
301-
302-
grunt.log.writeln('Stamped license on ' + String(tally).cyan + ' files.');
303-
});
304-
305252
};

tasks/bower_install.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
module.exports = function (grunt) {
4+
grunt.registerTask('bower_install', 'Installs Bower dependencies.', function () {
5+
var bower = require('bower'),
6+
done = this.async();
7+
8+
bower.commands.install()
9+
.on('log', function (data) {
10+
if (data.id !== 'install') { return; }
11+
grunt.log.writeln('bower ' + data.id.cyan + ' ' + data.message);
12+
})
13+
.on('end', function (results) {
14+
if (!Object.keys(results).length) {
15+
grunt.log.writeln('No bower packages to install.');
16+
}
17+
18+
done();
19+
});
20+
});
21+
};

tasks/license.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
module.exports = function (grunt) {
4+
grunt.registerMultiTask('license', 'Stamps license banners on files.', function () {
5+
var options = this.options({banner: ''}),
6+
banner = grunt.template.process(options.banner),
7+
tally = 0;
8+
9+
this.files.forEach(function (filePair) {
10+
filePair.src.forEach(function (file) {
11+
grunt.file.write(file, banner + grunt.file.read(file));
12+
tally += 1;
13+
});
14+
});
15+
16+
grunt.log.writeln('Stamped license on ' + String(tally).cyan + ' files.');
17+
});
18+
};

tasks/suppress.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
module.exports = function (grunt) {
4+
grunt.registerTask('suppress', 'Suppresses noisy logs', function () {
5+
var allowed = ['success', 'fail', 'warn', 'error'];
6+
7+
grunt.util.hooker.hook(grunt.log, {
8+
passName: true,
9+
10+
pre: function (name) {
11+
if (allowed.indexOf(name) === -1) {
12+
grunt.log.muted = true;
13+
}
14+
},
15+
16+
post: function () {
17+
grunt.log.muted = false;
18+
}
19+
});
20+
});
21+
};

0 commit comments

Comments
 (0)