-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
32 lines (29 loc) · 884 Bytes
/
test.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
var path = require('path')
var cp = require('child_process')
var b = require('substance-bundler')
b.task('build', function() {
b.make(require.resolve('./make.js'), 'test')
})
// TODO: tape is exiting the process when done :(
// so this task must be called at last
b.task('server', function() {
b.custom('Running nodejs tests...', {
execute: function() {
return new Promise(function(resolve, reject) {
const child = cp.fork(path.join(__dirname, '.test/run-cjs-tests.js'))
child.on('message', function(msg) {
if (msg === 'done') { resolve() }
})
child.on('error', function(error) {
reject(new Error(error))
})
child.on('close', function(exitCode) {
if (exitCode !== 0) {
process.exit(exitCode)
}
})
});
}
})
})
b.task('default', ['build', 'server'])