forked from Gitlink/gitlink-cli
35 lines
1.0 KiB
JavaScript
Executable File
35 lines
1.0 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
"use strict";
|
|
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const { execFileSync } = require("child_process");
|
|
|
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
const binaryPath = path.join(__dirname, "gitlink-cli" + ext);
|
|
|
|
if (!fs.existsSync(binaryPath)) {
|
|
console.error(
|
|
`Error: gitlink-cli binary not found at ${binaryPath}\n\n` +
|
|
`The binary was not downloaded during installation.\n` +
|
|
`This usually happens when the postinstall script failed (e.g. network issues).\n\n` +
|
|
`To fix, try one of:\n` +
|
|
` 1. Reinstall: npm install -g @gitlink-ai/cli\n` +
|
|
` 2. Manual download from:\n` +
|
|
` https://www.gitlink.org.cn/Gitlink/gitlink-cli/releases\n` +
|
|
` Then place the binary at: ${binaryPath}\n`
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
try {
|
|
execFileSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
|
|
} catch (err) {
|
|
if (err.status !== undefined) {
|
|
process.exit(err.status);
|
|
}
|
|
console.error(`Failed to run gitlink-cli: ${err.message}`);
|
|
process.exit(1);
|
|
}
|