-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.ts
42 lines (35 loc) · 1.23 KB
/
run.ts
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
import { spawn } from 'child_process';
import * as readline from 'readline';
async function runProcess(label: string, executable: string, ...args: string[]) {
return new Promise<void>((resolve, reject) => {
const process = spawn(executable, args);
const stdout = readline.createInterface({ input: process.stdout });
const stderr = readline.createInterface({ input: process.stderr });
stdout.on('line', (line) => console.log(`${label} ${line}`));
stderr.on('line', (line) => console.error(`${label} ${line}`));
process.on('error', (err) => {
stdout.close();
stderr.close();
reject(err);
});
process.on('exit', (code, signal) => {
stdout.close();
stderr.close();
if (code === 0) {
resolve();
} else if (code !== null) {
reject(new Error(`process exited with code ${code}`));
} else {
reject(new Error(`process exited with signal ${signal}`));
}
});
});
}
async function main() {
await Promise.all([
runProcess('[eventhub]', 'node', 'tests/e2e/javascript/eventhub.js'),
runProcess('[device] ', 'node', 'tests/e2e/javascript/device.js'),
runProcess('[app] ', 'node', 'tests/e2e/javascript/app.js'),
]);
}
main();