-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.js
More file actions
29 lines (25 loc) · 661 Bytes
/
Copy pathrun.js
File metadata and controls
29 lines (25 loc) · 661 Bytes
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
#!/usr/bin/env node
const { spawn } = require("child_process");
const runts = (cmd, args) => {
return new Promise((resolve, reject) => {
const ts = spawn(cmd, args, {
stdio: "inherit",
shell: true,
});
ts.on("close", (code) => {
if (code !== 0) {
reject(new Error(`Command failed with code ${code}`));
}
resolve();
});
});
};
const run_path = process.argv[2] || "src/index.ts";
runts("npx", ["tsc", "-b"])
.then(() => {
runts("npx", ["nodemon", "--exec", "npx tsc -b "]);
runts("npx", ["nodemon", "--exec", "npx ts-node " + run_path]);
})
.catch((err) => {
console.log(err);
});