-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (28 loc) · 750 Bytes
/
index.js
File metadata and controls
33 lines (28 loc) · 750 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
30
31
32
33
import { spawn } from "child_process";
import { createRequire } from "module";
import path from "path";
const require = createRequire(import.meta.url);
const entryFile = path.join(process.cwd(), "src", "index.ts");
let tsxCli;
try {
tsxCli = require.resolve("tsx/cli");
} catch {
console.error('Could not resolve tsx CLI module. Run "npm install".');
process.exit(1);
}
const child = spawn(process.execPath, [tsxCli, entryFile], {
stdio: "inherit",
shell: false,
env: process.env
});
child.on("error", (error) => {
console.error("Failed to launch TypeScript bot entrypoint:", error);
process.exit(1);
});
child.on("exit", (code, signal) => {
if (signal) {
process.kill(process.pid, signal);
return;
}
process.exit(code ?? 1);
});