forked from node-webrtc/node-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.js
executable file
·70 lines (58 loc) · 1.55 KB
/
karma.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
#!/usr/bin/env node
/* eslint no-console:0, no-process-env:0, no-process-exit:0 */
'use strict';
var fork = require('child_process').fork;
var spawn = require('child_process').spawn;
var join = require('path').join;
console.log('Starting server');
var server = fork(join(__dirname, '..', 'karma', 'server.js'));
console.log('Server PID is ' + server.pid);
server.once('error', function(error) {
console.error('Failed to start server: ' + error.stack);
exit(error.code);
});
server.once('exit', function(code) {
if (code) {
console.error('Server closed in error');
exit(code);
}
});
var configFile = join(__dirname, '..', 'karma', 'karma.conf.js');
console.log('Starting Karma');
var karma = spawn(join(__dirname, '..', 'node_modules', '.bin', 'karma'), ['start', configFile], {
env: Object.assign({
FILE: join(__dirname, '..', 'karma', 'client.js'),
}, process.env),
shell: true,
stdio: 'inherit'
});
console.log('Karma PID is ' + karma.pid);
karma.once('error', function(error) {
console.error('Failed to start Karma: ' + error.stack);
exit(1);
});
karma.once('exit', function(code) {
if (code) {
console.error('Karma closed in error');
exit(code);
} else {
console.log('Karma succeeded');
exit(0);
}
});
process.once('exit', exit);
process.once('SIGINT', exit);
process.once('SIGUSR1', exit);
process.once('SIGUSR2', exit);
process.once('uncaughtException', exit);
function exit(code) {
if (server) {
server.kill();
server = null;
}
if (karma) {
karma.kill();
karma = null;
}
process.exit(code);
}