forked from MallowTech/react-beautiful-dnd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser-test-harness.js
60 lines (55 loc) · 1.38 KB
/
browser-test-harness.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
// @flow
const childProcess = require('child_process');
const path = require('path');
const waitPort = require('wait-port');
const ports = require('./server-ports');
const storybook = childProcess.spawn(process.execPath, [
path.join('node_modules', '.bin', 'start-storybook'),
'-p',
`${ports.storybook}`,
]);
const cspServer = childProcess.spawn(process.execPath, [
path.join('csp-server', 'start.sh'),
`${ports.cspServer}`,
]);
process.on('exit', () => {
storybook.kill();
cspServer.kill();
});
Promise.all([
waitPort({
host: 'localhost',
port: ports.storybook,
timeout: 60000,
}),
waitPort({
host: 'localhost',
port: ports.cspServer,
timeout: 60000,
}),
])
.then(() => {
if (!process.argv[2]) {
// eslint-disable-next-line no-console
console.warn('Started servers but no command supplied to run after');
process.exit();
}
const child = childProcess.spawn(process.argv[2], process.argv.slice(3), {
stdio: 'inherit',
});
process.on('exit', () => {
child.kill();
});
child.on('exit', (code) => {
process.exit(code);
});
})
.catch((error) => {
// eslint-disable-next-line no-console
console.error('Unable to spin up standalone servers');
// eslint-disable-next-line no-console
console.error(error);
storybook.kill();
cspServer.kill();
process.exit(1);
});