This repository has been archived by the owner on Nov 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
87 lines (73 loc) · 2.66 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
86
"use strict";
const args = process.argv.filter(a => a.startsWith('--')).map(a => ` ${a}`);
// note we can't use npx mocha because npx initialises the thread pool
// before we can set UV_THREADPOOL_SIZE in lib/lora-comms.js
const test_cmd = `./node_modules/.bin/mocha --timeout 30000 --bail ${args}`;
const c8 = "npx c8 -x Gruntfile.js -x knexfile.js -x 'test/**'";
module.exports = function (grunt)
{
grunt.initConfig(
{
eslint: {
target: [
'Gruntfile.js',
'lib/**/*.js',
'test/**/*.js',
'example/**/*.js'
]
},
exec: Object.fromEntries(Object.entries({
seed: {
cwd: './test',
cmd: `../node_modules/.bin/knex seed:run -- ${args}`
},
test: {
cmd: test_cmd
},
cover: {
cmd: `${c8} ${test_cmd}`
},
cover_report: {
cmd: `${c8} report -r lcov`
},
cover_check: {
cmd: `${c8} check-coverage --statements 100 --branches 100 --functions 100 --lines 100`
},
documentation: {
cmd: [
'npx documentation build -c documentation.yml -f html -o docs lib/lorano.js',
'asciidoc -b docbook -o - README.adoc | pandoc -f docbook -t gfm -o README.md'
].join('&&')
},
run_example: {
cmd: 'node example/example.js'
}
}).map(([k, v]) => [k, { stdio: 'inherit', ...v }])),
copy: {
test_db: {
src: 'lorano.empty.sqlite3',
dest: 'test/lorano.sqlite3'
},
example_db: {
src: 'lorano.empty.sqlite3',
dest: 'example/lorano.sqlite3'
}
}
});
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask('lint', 'eslint');
grunt.registerTask('test', ['copy:test_db',
'exec:seed',
'exec:test']);
grunt.registerTask('coverage', ['copy:test_db',
'exec:seed',
'exec:cover',
'exec:cover_report',
'exec:cover_check']);
grunt.registerTask('example', ['copy:example_db',
'exec:run_example']);
grunt.registerTask('docs', 'exec:documentation');
grunt.registerTask('default', ['lint', 'test']);
};