-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.js
42 lines (39 loc) · 1.16 KB
/
start.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
import { spawn as __spawn } from "child_process";
import { existsSync } from "fs";
/**
* @param {Parameters<__spawn>} args
*/
function spawnPromise(...args) {
return new Promise(resolve => {
const child = __spawn(...args);
child.on("close", () => {
resolve();
});
child.on("error", error => {
console.log("Encountered an error while spawning:");
console.log("Args:", JSON.stringify(args));
console.log("Error:", error);
});
});
}
if(process.argv.includes("--dev")) {
spawnPromise("python", ["main.py"], {
stdio: "inherit", shell: true
});
spawnPromise("npm", ["run", "dev"], {
stdio: "inherit", shell: true
});
} else {
if(false == existsSync("./.next/BUILD_ID") || process.argv.includes("--build")) {
console.log("Compiling...");
await spawnPromise("npm", ["run", "build"], {
stdio: "inherit", shell: true
});
}
spawnPromise("python", ["main.py", "--production"], {
stdio: "inherit", shell: true
});
spawnPromise("npm", ["run", "start"], {
stdio: "inherit", shell: true
});
}