-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
75 lines (68 loc) · 2 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
var child = require('child_process'),
exec = child.exec,
BIN = './node_modules/.bin/';
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.initConfig({
jshint: {
options: {
camelcase: true,
curly: true,
eqeqeq: true,
immed: true,
indent: 4,
latedef: 'nofunc',
newcap: true,
noarg: true,
nonew: true,
undef: true,
unused: true,
trailing: true,
loopfunc: true,
proto: true,
node: true,
'-W015': true,
'-W030': true,
'-W104': true, // 'const' is only available in JavaScript 1.7
'-W068': true // Wrapping non-IIFE function literals in parens is unnecessary
},
src: ['lib/**/*.js', 'commands/**/*.js']
},
// Configure a mochaTest task
mochaTest: {
test: {
options: {
reporter: 'spec',
timeout: process.env.TRAVIS ? '60000' : '30000'
},
src: ['specs/**/*.js']
}
},
clean: {
test: ['_tmp','build','test*']
},
coverage: {
src: []
}
});
var test_tasks = ['clean:test','mochaTest:test'];
grunt.registerTask('run_coverage', 'generate test coverage report', function() {
var done = this.async(),
cmd = BIN + 'istanbul cover --report html ' + BIN + '_mocha -- specs --recursive';
grunt.log.debug(cmd);
exec(cmd, function(err, stdout, stderr) {
if (err) { grunt.fail.fatal(err); }
if (/No coverage information was collected/.test(stderr)) {
grunt.fail.warn('No coverage information was collected. Report not generated.');
} else {
grunt.log.ok('test coverage report generated to "./coverage/index.html"');
}
done();
});
});
grunt.registerTask('test', test_tasks);
grunt.registerTask('coverage', ['clean:test','run_coverage']);
grunt.registerTask('default', 'test');
};