cache platform binary in postinstall for faster startup (#14467)
This commit is contained in:
@@ -25,6 +25,12 @@ if (envPath) {
|
|||||||
const scriptPath = fs.realpathSync(__filename)
|
const scriptPath = fs.realpathSync(__filename)
|
||||||
const scriptDir = path.dirname(scriptPath)
|
const scriptDir = path.dirname(scriptPath)
|
||||||
|
|
||||||
|
//
|
||||||
|
const cached = path.join(scriptDir, ".opencode")
|
||||||
|
if (fs.existsSync(cached)) {
|
||||||
|
run(cached)
|
||||||
|
}
|
||||||
|
|
||||||
const platformMap = {
|
const platformMap = {
|
||||||
darwin: "darwin",
|
darwin: "darwin",
|
||||||
linux: "linux",
|
linux: "linux",
|
||||||
|
|||||||
@@ -109,8 +109,14 @@ async function main() {
|
|||||||
// On non-Windows platforms, just verify the binary package exists
|
// On non-Windows platforms, just verify the binary package exists
|
||||||
// Don't replace the wrapper script - it handles binary execution
|
// Don't replace the wrapper script - it handles binary execution
|
||||||
const { binaryPath } = findBinary()
|
const { binaryPath } = findBinary()
|
||||||
console.log(`Platform binary verified at: ${binaryPath}`)
|
const target = path.join(__dirname, "bin", ".opencode")
|
||||||
console.log("Wrapper script will handle binary execution")
|
if (fs.existsSync(target)) fs.unlinkSync(target)
|
||||||
|
try {
|
||||||
|
fs.linkSync(binaryPath, target)
|
||||||
|
} catch {
|
||||||
|
fs.copyFileSync(binaryPath, target)
|
||||||
|
}
|
||||||
|
fs.chmodSync(target, 0o755)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to setup opencode binary:", error.message)
|
console.error("Failed to setup opencode binary:", error.message)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user