mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-25 03:34:22 +01:00
sync
This commit is contained in:
29
packages/opencode/bin/opencode.mjs
Normal file
29
packages/opencode/bin/opencode.mjs
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env node
|
||||
import { createRequire } from "node:module"
|
||||
const require = createRequire(import.meta.url)
|
||||
import path from "path"
|
||||
import { execFileSync } from "child_process"
|
||||
let resolved = process.env.SST_BIN_PATH
|
||||
if (!resolved) {
|
||||
const name = `opencode-${process.platform}-${process.arch}`
|
||||
const binary = process.platform === "win32" ? "opencode.exe" : "opencode"
|
||||
try {
|
||||
resolved = require.resolve(path.join(name, "bin", binary))
|
||||
} catch (ex) {
|
||||
console.error(
|
||||
`It seems that your package manager failed to install the right version of the SST CLI for your platform. You can try manually installing the "${name}" package`,
|
||||
)
|
||||
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
process.on("SIGINT", () => {})
|
||||
|
||||
try {
|
||||
execFileSync(resolved, process.argv.slice(2), {
|
||||
stdio: "inherit",
|
||||
})
|
||||
} catch (ex) {
|
||||
process.exit(1)
|
||||
}
|
||||
Reference in New Issue
Block a user