This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.js
79 lines (67 loc) · 1.82 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
76
77
78
79
'use strict';
var path = require('path');
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
grunt.initConfig({
settings: {
},
clean: {
docs: ['./docs'],
node: ['./node_modules'],
coverage: {
src: ['./coverage']
}
},
env : {
options : {
},
test : {
NODE_ENV : 'test'
}
},
exec: {
istanbul: {
cmd: function () {
var cover = 'istanbul cover --x "" node_modules/mocha/bin/_mocha -- --timeout 60000 --reporter spec tests/index.js';
var report = 'istanbul' + ' report ' + 'cobertura';
return cover + ' && ' + report;
}
},
mocha: {
cmd: function runMocha(xarg) {
var src = [];
var arg = xarg ? xarg.toLowerCase() : '';
if (arg === 'some-subtask'){
src = [ ];
} else {
src = [
'tests/*.js',
'!node_modules/**/*.js'
];
}
var files = grunt.file.expand(src);
var bin = path.resolve(__dirname, './node_modules/.bin/mocha');
var options = ' --compilers js:babel-core/register --colors --reporter spec --timeout 20000 ';
var cmd = bin + options + files.join(' ');
console.log(cmd);
return cmd;
}
}
},
jsdoc: {
dist: {
src: ['src/*.js', '!Gruntfile.js'],
options: {
destination: 'docs'
}
}
}
});
grunt.registerTask('coverage', ['clean:coverage', 'env:test', 'exec:istanbul']);
grunt.registerTask('docs', [ 'clean:docs', 'jsdoc' ]);
grunt.registerTask('test', 'Run Tests', function () {
grunt.task.run(['env:test', 'exec:mocha']);
});
grunt.registerTask('default', ['test']);
};