/
Gruntfile.js
52 lines (45 loc) · 1.53 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'use strict';
var glob = require('glob');
var all = glob.sync('**/*.js');
var vendor = process(['node_modules/', 'bower_components/', 'components/', 'vendor/', 'build/', 'ch01/', '/app/templates/compiledTemplates.js', 'bundle.js'], unmatched, all);
var es6_globs = ['ch05/17_harmony-traceur/', 'ch06/12_generator-basics/', 'ch06/13_generator-flow/'];
var es6 = process(es6_globs, matched, vendor);
var browser = process(['public/'], matched, vendor);
var node = process(['public/', 'appendix/picking-your-build-tool/'].concat(es6_globs), unmatched, vendor);
function process (by, criteria, files) {
return files.filter(where);
function where (path) {
return by.every(criteria.bind(path));
}
}
function unmatched (expression) {
return this.indexOf(expression) === -1; // jshint ignore:line
}
function matched (expression) {
return this.indexOf(expression) !== -1; // jshint ignore:line
}
module.exports = function(grunt){
grunt.initConfig({
jshint: {
node: {
files: { src: node },
options: { jshintrc: '.jshintrc-node' }
},
browser: {
files: { src: browser },
options: { jshintrc: '.jshintrc-browser' }
},
es6: {
files: { src: es6 },
options: { jshintrc: '.jshintrc-es6' }
},
options: {
reporter: require('jshint-stylish')
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('lint', ['jshint:node', 'jshint:browser']);
grunt.registerTask('default', ['lint']);
grunt.registerTask('ci', ['lint']);
};