-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrunt.js
57 lines (51 loc) · 1.59 KB
/
grunt.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
var child_process = require('child_process'),
path = require('path'),
fs = require('fs'),
sequence = require('sequence'),
when = require('when');
module.exports = function(grunt){
// Project configuration.
grunt.initConfig({
lint: {
all: ['grunt.js', 'lib/**/*.js', 'test/**/*.js']
},
jshint: {
options: {
node: true
}
}
});
grunt.registerTask('test', function(){
var done = this.async();
grunt.helper('jscoverage').then(function(){
child_process.exec("COVERAGE=1 mocha --reporter html-cov > coverage.html",
{'COVERAGE': 1, 'NODE_ENVIRONMENT': 'testing'},
function(err, stdout, stderr) {
if(err){
grunt.warn(err);
}
done();
});
});
});
grunt.registerHelper('jscoverage', function(){
var d = when.defer();
sequence(this)
.then(function(next){
path.exists(path.resolve('./lib-cov'), next);
})
.then(function(next, exists){
if(exists){
return fs.rmdir(path.resolve('./lib-cov'), next);
}
return next();
})
.then(function(next){
child_process.exec("jscoverage --no-highlight ./lib ./lib-cov", function(err, stdout, stderr) {
d.resolve();
});
});
return d.promise;
});
grunt.registerTask('default', 'lint test');
};