Skip to content

Commit 8a136d8

Browse files
committed
fix: anchor bin/ to root in .gitignore
"bin/" was matching npm/bin/ directory, preventing the npm distribution script from being tracked. Changed to "/bin/" to only match the root binary output directory.
1 parent 728e36f commit 8a136d8

2 files changed

Lines changed: 57 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Binaries
2-
bin/
2+
/bin/
33
*.exe
44
*.exe~
55
*.dll

npm/bin/lark-daemon.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env node
2+
3+
const { spawn } = require("child_process");
4+
const path = require("path");
5+
const fs = require("fs");
6+
7+
const PLATFORM_MAP = {
8+
"linux-x64": "lark-daemon-linux-amd64",
9+
"linux-arm64": "lark-daemon-linux-arm64",
10+
"darwin-x64": "lark-daemon-darwin-amd64",
11+
"darwin-arm64": "lark-daemon-darwin-arm64",
12+
"win32-x64": "lark-daemon-windows-amd64.exe",
13+
};
14+
15+
function getBinaryName() {
16+
const key = `${process.platform}-${process.arch}`;
17+
const name = PLATFORM_MAP[key];
18+
if (!name) {
19+
console.error(`Unsupported platform: ${key}`);
20+
console.error(`Supported: ${Object.keys(PLATFORM_MAP).join(", ")}`);
21+
process.exit(1);
22+
}
23+
return name;
24+
}
25+
26+
function getBinaryPath() {
27+
const name = getBinaryName();
28+
return path.join(__dirname, name);
29+
}
30+
31+
const binaryPath = getBinaryPath();
32+
33+
if (!fs.existsSync(binaryPath)) {
34+
console.error("lark-daemon binary not found.");
35+
console.error("Run `npm install` in this package directory to download it,");
36+
console.error("or download manually from:");
37+
console.error(" https://github.com/GrayCodeAI/lark-daemon/releases");
38+
process.exit(1);
39+
}
40+
41+
const args = process.argv.slice(2);
42+
const child = spawn(binaryPath, args, { stdio: "inherit" });
43+
44+
child.on("exit", (code) => {
45+
process.exit(code ?? 0);
46+
});
47+
48+
child.on("error", (err) => {
49+
if (err.code === "EACCES") {
50+
console.error(`Permission denied: ${binaryPath}`);
51+
console.error(`Run: chmod +x ${binaryPath}`);
52+
} else {
53+
console.error(err);
54+
}
55+
process.exit(1);
56+
});

0 commit comments

Comments
 (0)