|
1 | 1 | #!/usr/bin/env node |
2 | 2 |
|
3 | 3 | // Entry point for effect-devtools npm package |
4 | | -// Runs the bundled JavaScript version |
| 4 | +// Runs the platform-specific compiled binary |
5 | 5 |
|
6 | 6 | import { fileURLToPath } from "url"; |
7 | 7 | import { dirname, join } from "path"; |
| 8 | +import { spawn } from "child_process"; |
| 9 | +import { existsSync } from "fs"; |
8 | 10 |
|
9 | 11 | const __filename = fileURLToPath(import.meta.url); |
10 | 12 | const __dirname = dirname(__filename); |
11 | 13 |
|
12 | | -// Import and run the bundled app |
13 | | -await import(join(__dirname, "..", "dist", "index.js")); |
| 14 | +const platform = process.platform === "win32" ? "windows" : process.platform; |
| 15 | +const arch = process.arch; |
| 16 | +const ext = process.platform === "win32" ? ".exe" : ""; |
| 17 | + |
| 18 | +const binaryName = `effect-devtools-${platform}-${arch}`; |
| 19 | +const binaryPath = join(__dirname, "..", "dist", binaryName, binaryName + ext); |
| 20 | + |
| 21 | +if (!existsSync(binaryPath)) { |
| 22 | + console.error(`Binary not found for your platform: ${platform}-${arch}`); |
| 23 | + console.error(`Expected: ${binaryPath}`); |
| 24 | + console.error(`\nSupported platforms: linux-x64, darwin-x64, windows-x64`); |
| 25 | + process.exit(1); |
| 26 | +} |
| 27 | + |
| 28 | +const child = spawn(binaryPath, process.argv.slice(2), { |
| 29 | + stdio: "inherit", |
| 30 | +}); |
| 31 | + |
| 32 | +child.on("close", (code) => { |
| 33 | + process.exit(code ?? 0); |
| 34 | +}); |
0 commit comments