@stonerzju/opencode 1.2.21 → 1.2.22
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.
- package/bin/opencode +22 -18
- package/package.json +1 -1
package/bin/opencode
CHANGED
|
@@ -6,23 +6,14 @@ import path from "path"
|
|
|
6
6
|
import os from "os"
|
|
7
7
|
import { fileURLToPath } from "url"
|
|
8
8
|
|
|
9
|
-
function run(target) {
|
|
10
|
-
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
11
|
-
stdio: "inherit",
|
|
12
|
-
cwd: process.cwd(),
|
|
13
|
-
})
|
|
14
|
-
if (result.error) {
|
|
15
|
-
console.error(result.error.message)
|
|
16
|
-
process.exit(1)
|
|
17
|
-
}
|
|
18
|
-
const code = typeof result.status === "number" ? result.status : 0
|
|
19
|
-
process.exit(code)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
9
|
const envPath = process.env.OPENCODE_BIN_PATH
|
|
23
10
|
|
|
24
11
|
if (envPath) {
|
|
25
|
-
|
|
12
|
+
const result = childProcess.spawnSync(envPath, process.argv.slice(2), {
|
|
13
|
+
stdio: "inherit",
|
|
14
|
+
cwd: process.cwd(),
|
|
15
|
+
})
|
|
16
|
+
process.exit(result.status ?? 1)
|
|
26
17
|
} else {
|
|
27
18
|
const __filename = fileURLToPath(import.meta.url)
|
|
28
19
|
const __dirname = path.dirname(__filename)
|
|
@@ -52,20 +43,33 @@ if (envPath) {
|
|
|
52
43
|
}
|
|
53
44
|
|
|
54
45
|
if (bunPath) {
|
|
55
|
-
|
|
46
|
+
// Use execSync instead of spawnSync for better handling
|
|
47
|
+
const result = childProcess.spawnSync(bunPath, [target, ...process.argv.slice(2)], {
|
|
48
|
+
stdio: "inherit",
|
|
49
|
+
cwd: process.cwd(),
|
|
50
|
+
env: { ...process.env }
|
|
51
|
+
})
|
|
52
|
+
process.exit(result.status ?? 1)
|
|
56
53
|
} else {
|
|
57
54
|
// Try to find bun using which command
|
|
58
55
|
try {
|
|
59
56
|
const whichResult = childProcess.execSync("which bun", { encoding: "utf-8" }).trim()
|
|
60
57
|
if (whichResult && fs.existsSync(whichResult)) {
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
const result = childProcess.spawnSync(whichResult, [target, ...process.argv.slice(2)], {
|
|
59
|
+
stdio: "inherit",
|
|
60
|
+
cwd: process.cwd(),
|
|
61
|
+
})
|
|
62
|
+
process.exit(result.status ?? 1)
|
|
63
63
|
}
|
|
64
64
|
} catch {
|
|
65
65
|
// which command failed, continue to fallback
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// Fallback: try to run with bun from PATH
|
|
69
|
-
|
|
69
|
+
const result = childProcess.spawnSync("bun", [target, ...process.argv.slice(2)], {
|
|
70
|
+
stdio: "inherit",
|
|
71
|
+
cwd: process.cwd(),
|
|
72
|
+
})
|
|
73
|
+
process.exit(result.status ?? 1)
|
|
70
74
|
}
|
|
71
75
|
}
|