-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.js
74 lines (62 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
/*jslint node: true */
"use strict";
const c8 = "npx c8 -x Gruntfile.js -x 'test/**'";
var remote_index = -1;
for (var i = 0; i < process.argv.length; i += 1)
{
if (process.argv[i].lastIndexOf('--remote=', 0) === 0)
{
remote_index = i;
break;
}
}
module.exports = function (grunt)
{
grunt.initConfig(
{
jshint: {
src: [ 'Gruntfile.js', 'index.js', 'test/**/*.js' ],
options: {
esversion: 11
}
},
mochaTest: {
src: 'test/test_spec.js'
},
apidox: {
input: 'index.js',
output: 'README.md',
fullSourceDescription: true,
extraHeadingLevels: 1
},
exec: Object.fromEntries(Object.entries({
cover: {
cmd: `${c8} npx grunt test ${remote_index < 0 ? '' : process.argv.slice(remote_index).join(' ')}`
},
cover_report: {
cmd: `${c8} report -r lcov`
},
cover_check: {
cmd: `${c8} check-coverage --statements 100 --branches 100 --functions 100 --lines 100`
},
diagrams: {
cmd: 'dot diagrams/how_it_works.dot -Tsvg -odiagrams/how_it_works.svg'
},
pack: {
command: './pack.sh'
}
}).map(([k, v]) => [k, { stdio: 'inherit', ...v }]))
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-apidox');
grunt.loadNpmTasks('grunt-exec');
grunt.registerTask('lint', 'jshint');
grunt.registerTask('pack', 'exec:pack');
grunt.registerTask('test', 'mochaTest');
grunt.registerTask('docs', ['exec:diagrams', 'apidox']);
grunt.registerTask('coverage', ['exec:cover',
'exec:cover_report',
'exec:cover_check']);
grunt.registerTask('default', ['lint', 'test']);
};