-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner.js
47 lines (36 loc) · 1.06 KB
/
runner.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
// Usage: node runner.js <NODE_ENV>
const { spawn } = require("child_process");
const path = require("path");
const env = process.argv[2] || "development";
const client = spawn("npm", ["run", "start"], {
cwd: path.join(__dirname, "client"),
env: { ...process.env, NODE_ENV: env },
});
const server = spawn("npm", ["run", "start"], {
cwd: path.join(__dirname, "server"),
env: { ...process.env, NODE_ENV: env },
});
client.stdout.on("data", (data) => {
console.log(`client: ${data}`);
});
server.stdout.on("data", (data) => {
console.log(`server: ${data}`);
});
client.stderr.on("data", (data) => {
console.error(`client: ${data}`);
});
server.stderr.on("data", (data) => {
console.error(`server: ${data}`);
});
client.on("close", (code) => {
console.log(`client process exited with code ${code}`);
});
server.on("close", (code) => {
console.log(`server process exited with code ${code}`);
});
client.on("error", (err) => {
console.error(`client process error: ${err}`);
});
server.on("error", (err) => {
console.error(`server process error: ${err}`);
});