-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathGruntfile.js
85 lines (71 loc) · 3.29 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
80
81
82
83
84
85
"use strict";
const c8 = "npx c8 -x Gruntfile.js -x 'test/**'";
module.exports = function (grunt)
{
grunt.initConfig(
{
jshint: {
src: [ 'lib/**/*.js', 'test/**/*.js' ],
options: {
node: true,
esversion: 11,
expr: true
}
},
mochaTest: {
src: 'test/*.js',
options: {
bail: true
}
},
exec: {
build: {
cmd: 'node-gyp build --debug'
},
rebuild: {
cmd: 'node-gyp rebuild --debug'
},
cover_build: {
cmd: 'node-gyp rebuild --debug --coverage=true'
},
cover_init: {
cmd: 'mkdir -p coverage && rm -f coverage/lcov_addon_base.info && lcov --rc lcov_branch_coverage=0 --zerocounters --directory build && lcov --rc lcov_branch_coverage=0 --capture --initial --directory build --output-file coverage/lcov_addon_base.info'
},
cover: {
cmd: `${c8} npx grunt test`
},
cover_lcov: {
cmd: `rm -f coverage/lcov.info && ${c8} report -r lcovonly && rm -f coverage/lcov_addon.info && lcov --rc lcov_branch_coverage=0 --capture --directory build --output-file coverage/lcov_addon.info && rm -f coverage/lcov_combined.info && lcov --rc lcov_branch_coverage=1 --add-tracefile coverage/lcov.info --add-tracefile coverage/lcov_addon_base.info --add-tracefile coverage/lcov_addon.info --output-file coverage/lcov_combined.info && rm -f coverage/lcov_final.info && lcov --rc lcov_branch_coverage=1 --remove coverage/lcov_combined.info '/usr/*' $PWD'/node_modules/*' --output-file coverage/lcov_final.info`
},
cover_report: {
cmd: 'genhtml --rc lcov_branch_coverage=1 --demangle-cpp -o coverage/lcov-report coverage/lcov_final.info'
},
cover_check: {
// lines% functions% branches%
// Branches for C++ are disabled because gcov results are
// messed up by exceptions.
cmd: "if [ \"$(lcov --rc lcov_branch_coverage=1 --list coverage/lcov_final.info | grep Total | grep -o '[0-9.]\\+%' | tr '\\n' ' ')\" != '100% 100% 100% ' ]; then exit 1; fi"
},
documentation: {
cmd: [
'npx documentation build -f html -o docs docs.js',
'asciidoc -b docbook -o - README.adoc | pandoc -f docbook -t gfm -o README.md'
].join('&&')
}
}
})
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-exec');
grunt.registerTask('lint', 'jshint');
grunt.registerTask('build', 'exec:build');
grunt.registerTask('rebuild', 'exec:rebuild');
grunt.registerTask('test', 'mochaTest');
grunt.registerTask('coverage', ['exec:cover_build',
'exec:cover_init',
'exec:cover',
'exec:cover_lcov',
'exec:cover_report',
'exec:cover_check']);
grunt.registerTask('docs', 'exec:documentation');
};