opencode-ai-nofc 1.14.41 → 1.14.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/opencode +32 -12
  2. package/package.json +7 -7
package/bin/opencode CHANGED
@@ -5,31 +5,51 @@ const fs = require("fs")
5
5
  const path = require("path")
6
6
  const os = require("os")
7
7
 
8
+ const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP"]
9
+
8
10
  function run(target) {
9
- const result = childProcess.spawnSync(target, process.argv.slice(2), {
11
+ const child = childProcess.spawn(target, process.argv.slice(2), {
10
12
  stdio: "inherit",
11
13
  })
12
- if (result.error) {
13
- console.error(result.error.message)
14
+
15
+ child.on("error", (error) => {
16
+ console.error(error.message)
14
17
  process.exit(1)
18
+ })
19
+
20
+ const forwarders = {}
21
+ for (const signal of forwardedSignals) {
22
+ forwarders[signal] = () => {
23
+ try {
24
+ child.kill(signal)
25
+ } catch {
26
+ // The child may have already exited.
27
+ }
28
+ }
29
+ process.on(signal, forwarders[signal])
15
30
  }
16
- const code = typeof result.status === "number" ? result.status : 0
17
- process.exit(code)
31
+
32
+ child.on("exit", (code, signal) => {
33
+ for (const forwardedSignal of forwardedSignals) {
34
+ process.removeListener(forwardedSignal, forwarders[forwardedSignal])
35
+ }
36
+
37
+ if (signal) {
38
+ process.kill(process.pid, signal)
39
+ return
40
+ }
41
+
42
+ process.exit(typeof code === "number" ? code : 0)
43
+ })
18
44
  }
19
45
 
20
46
  const envPath = process.env.OPENCODE_BIN_PATH
21
- if (envPath) {
22
- run(envPath)
23
- }
24
47
 
25
48
  const scriptPath = fs.realpathSync(__filename)
26
49
  const scriptDir = path.dirname(scriptPath)
27
50
 
28
51
  //
29
52
  const cached = path.join(scriptDir, ".opencode")
30
- if (fs.existsSync(cached)) {
31
- run(cached)
32
- }
33
53
 
34
54
  const platformMap = {
35
55
  darwin: "darwin",
@@ -166,7 +186,7 @@ function findBinary(startDir) {
166
186
  }
167
187
  }
168
188
 
169
- const resolved = findBinary(scriptDir)
189
+ const resolved = envPath || (fs.existsSync(cached) ? cached : findBinary(scriptDir))
170
190
  if (!resolved) {
171
191
  console.error(
172
192
  "It seems that your package manager failed to install the right version of the opencode CLI for your platform. You can try manually installing " +
package/package.json CHANGED
@@ -6,14 +6,14 @@
6
6
  "scripts": {
7
7
  "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
8
8
  },
9
- "version": "1.14.41",
9
+ "version": "1.14.48",
10
10
  "license": "MIT",
11
11
  "optionalDependencies": {
12
- "opencode-ai-nofc-darwin-arm64": "1.14.41",
13
- "opencode-ai-nofc-windows-x64": "1.14.41",
14
- "opencode-ai-nofc-linux-arm64": "1.14.41",
15
- "opencode-ai-nofc-linux-x64": "1.14.41",
16
- "opencode-ai-nofc-darwin-x64": "1.14.41",
17
- "opencode-ai-nofc-windows-arm64": "1.14.41"
12
+ "opencode-ai-nofc-darwin-arm64": "1.14.48",
13
+ "opencode-ai-nofc-windows-x64": "1.14.48",
14
+ "opencode-ai-nofc-linux-arm64": "1.14.48",
15
+ "opencode-ai-nofc-linux-x64": "1.14.48",
16
+ "opencode-ai-nofc-darwin-x64": "1.14.48",
17
+ "opencode-ai-nofc-windows-arm64": "1.14.48"
18
18
  }
19
19
  }