Repository navigation
Expand file tree
/
Copy pathdev.ts
More file actions
55 lines (50 loc) · 1.38 KB
/
Copy pathdev.ts
File metadata and controls
55 lines (50 loc) · 1.38 KB
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
48
49
50
51
52
53
54
55
import { dirname, resolve } from "node:path"
import { fileURLToPath } from "node:url"
import { buildLocalIcn } from "../inference/scripts/build-local"
const PROJECT_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..")
const run = async (
command: string[],
env: Record<string, string | undefined> = process.env,
): Promise<number> => {
const child = Bun.spawn(command, {
cwd: PROJECT_ROOT,
env,
stdin: "inherit",
stdout: "inherit",
stderr: "inherit",
})
const interrupt = () => child.kill("SIGINT")
const terminate = () => child.kill("SIGTERM")
process.once("SIGINT", interrupt)
process.once("SIGTERM", terminate)
try {
return await child.exited
} finally {
process.off("SIGINT", interrupt)
process.off("SIGTERM", terminate)
}
}
const versionExit = await run([
"bun",
"run",
"dev:version",
])
if (versionExit !== 0) process.exit(versionExit)
const explicit = process.env.MAGNITUDE_ICN_PATH?.trim()
let icnPath: string
if (explicit) {
icnPath = resolve(explicit)
console.log(`[dev] Using ICN: ${icnPath}`)
} else {
const built = await buildLocalIcn()
icnPath = built.installationPath
console.log(`[dev] Using ${built.backend} ICN: ${icnPath}`)
}
const clientExit = await run(
["bun", "run", "cli/src/index.tsx", ...process.argv.slice(2)],
{
...process.env,
MAGNITUDE_ICN_PATH: icnPath,
},
)
process.exit(clientExit)