diff options
| author | Aiden Cline <[email protected]> | 2026-02-20 09:26:13 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-20 09:26:13 -0600 |
| commit | c79f1a72d8f4b1a270c234f967bd9f2bed72a1f0 (patch) | |
| tree | 22fd85610e8cdb0d181cec1a8e3315360fbb2c06 | |
| parent | 9c5bbba6eab4466621028e3cf3467119051423fb (diff) | |
| download | opencode-c79f1a72d8f4b1a270c234f967bd9f2bed72a1f0.tar.gz opencode-c79f1a72d8f4b1a270c234f967bd9f2bed72a1f0.zip | |
cache platform binary in postinstall for faster startup (#14396)
| -rwxr-xr-x | packages/opencode/bin/opencode | 5 | ||||
| -rw-r--r-- | packages/opencode/script/postinstall.mjs | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/packages/opencode/bin/opencode b/packages/opencode/bin/opencode index d73bbce26..7d0fabaf3 100755 --- a/packages/opencode/bin/opencode +++ b/packages/opencode/bin/opencode @@ -25,6 +25,11 @@ if (envPath) { const scriptPath = fs.realpathSync(__filename) const scriptDir = path.dirname(scriptPath) +const cached = path.join(scriptDir, ".opencode") +if (fs.existsSync(cached)) { + run(cached) +} + const platformMap = { darwin: "darwin", linux: "linux", diff --git a/packages/opencode/script/postinstall.mjs b/packages/opencode/script/postinstall.mjs index e8b5e995c..67b2e35fc 100644 --- a/packages/opencode/script/postinstall.mjs +++ b/packages/opencode/script/postinstall.mjs @@ -106,11 +106,15 @@ async function main() { return } - // On non-Windows platforms, just verify the binary package exists - // Don't replace the wrapper script - it handles binary execution const { binaryPath } = findBinary() - console.log(`Platform binary verified at: ${binaryPath}`) - console.log("Wrapper script will handle binary execution") + const target = path.join(__dirname, "..", "bin", ".opencode") + if (fs.existsSync(target)) fs.unlinkSync(target) + try { + fs.linkSync(binaryPath, target) + } catch { + fs.copyFileSync(binaryPath, target) + } + fs.chmodSync(target, 0o755) } catch (error) { console.error("Failed to setup opencode binary:", error.message) process.exit(1) |
