Skip to content

Commit dcaa03a

Browse files
committed
Add bin wrapper script and remove bin from gitignore
1 parent 11af9ed commit dcaa03a

2 files changed

Lines changed: 66 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ node_modules
22
dist
33
*.log
44
.DS_Store
5-
bin
5+

bin/effect-devtools

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env node
2+
3+
// Installer script for effect-devtools
4+
// Downloads the appropriate binary for the current platform
5+
6+
import { createRequire } from "module";
7+
import { platform, arch } from "os";
8+
import { existsSync } from "fs";
9+
import { join, dirname } from "path";
10+
import { fileURLToPath } from "url";
11+
12+
const __filename = fileURLToPath(import.meta.url);
13+
const __dirname = dirname(__filename);
14+
15+
const require = createRequire(import.meta.url);
16+
const pkg = require("../package.json");
17+
18+
// Map platform/arch to binary names
19+
const PLATFORMS = {
20+
darwin: {
21+
x64: "effect-devtools-darwin-x64",
22+
arm64: "effect-devtools-darwin-arm64",
23+
},
24+
linux: {
25+
x64: "effect-devtools-linux-x64",
26+
arm64: "effect-devtools-linux-arm64",
27+
},
28+
win32: {
29+
x64: "effect-devtools-windows-x64.exe",
30+
},
31+
};
32+
33+
const currentPlatform = platform();
34+
const currentArch = arch();
35+
36+
const binaryName = PLATFORMS[currentPlatform]?.[currentArch];
37+
38+
if (!binaryName) {
39+
console.error(
40+
`Unsupported platform: ${currentPlatform} ${currentArch}`
41+
);
42+
console.error("Supported platforms:");
43+
console.error(JSON.stringify(PLATFORMS, null, 2));
44+
process.exit(1);
45+
}
46+
47+
const binaryPath = join(__dirname, "..", "dist", binaryName.replace(".exe", ""), binaryName);
48+
49+
if (!existsSync(binaryPath)) {
50+
console.error(`Binary not found: ${binaryPath}`);
51+
console.error("Please report this issue at:");
52+
console.error(pkg.bugs.url);
53+
process.exit(1);
54+
}
55+
56+
// Re-export the binary
57+
import { spawn } from "child_process";
58+
59+
const child = spawn(binaryPath, process.argv.slice(2), {
60+
stdio: "inherit",
61+
});
62+
63+
child.on("exit", (code) => {
64+
process.exit(code || 0);
65+
});

0 commit comments

Comments
 (0)