GeezerVison is showing github.com — cache platform binary in postinstall for faster startup (#14467) · rodboev/opencode@1d9f05e
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/opencode/bin/opencode +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -25,6 +25,12 @@ if (envPath) { |
25 | 25 | const scriptPath = fs.realpathSync(__filename) |
26 | 26 | const scriptDir = path.dirname(scriptPath) |
27 | 27 |
|
| 28 | +// |
| 29 | +const cached = path.join(scriptDir, ".opencode") |
| 30 | +if (fs.existsSync(cached)) { |
| 31 | + run(cached) |
| 32 | +} |
| 33 | + |
28 | 34 | const platformMap = { |
29 | 35 | darwin: "darwin", |
30 | 36 | linux: "linux", |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/opencode/script/postinstall.mjs +8-2Lines changed: 8 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -109,8 +109,14 @@ async function main() { |
109 | 109 | // On non-Windows platforms, just verify the binary package exists |
110 | 110 | // Don't replace the wrapper script - it handles binary execution |
111 | 111 | const { binaryPath } = findBinary() |
112 | | - console.log(`Platform binary verified at: ${binaryPath}`) |
113 | | - console.log("Wrapper script will handle binary execution") |
| 112 | + const target = path.join(__dirname, "bin", ".opencode") |
| 113 | + if (fs.existsSync(target)) fs.unlinkSync(target) |
| 114 | + try { |
| 115 | + fs.linkSync(binaryPath, target) |
| 116 | + } catch { |
| 117 | + fs.copyFileSync(binaryPath, target) |
| 118 | + } |
| 119 | + fs.chmodSync(target, 0o755) |
114 | 120 | } catch (error) { |
115 | 121 | console.error("Failed to setup opencode binary:", error.message) |
116 | 122 | process.exit(1) |
|