fix(cli-run): skip unresolved opencode bin path injection

This commit is contained in:
YeonGyu-Kim
2026-02-18 15:49:44 +09:00
parent 768b35bba6
commit 6a4d86b86a
2 changed files with 29 additions and 2 deletions
+19 -2
View File
@@ -10,9 +10,10 @@ describe("prependResolvedOpencodeBinToPath", () => {
PATH: "/Users/yeongyu/node_modules/.bin:/usr/bin",
}
const resolver = () => "/tmp/bunx-123/node_modules/opencode-ai/bin/opencode"
const pathExists = () => true
//#when
prependResolvedOpencodeBinToPath(env, resolver)
prependResolvedOpencodeBinToPath(env, resolver, pathExists)
//#then
expect(env.PATH).toBe(
@@ -26,9 +27,10 @@ describe("prependResolvedOpencodeBinToPath", () => {
PATH: "/tmp/bunx-123/node_modules/opencode-ai/bin:/usr/bin",
}
const resolver = () => "/tmp/bunx-123/node_modules/opencode-ai/bin/opencode"
const pathExists = () => true
//#when
prependResolvedOpencodeBinToPath(env, resolver)
prependResolvedOpencodeBinToPath(env, resolver, pathExists)
//#then
expect(env.PATH).toBe("/tmp/bunx-123/node_modules/opencode-ai/bin:/usr/bin")
@@ -49,4 +51,19 @@ describe("prependResolvedOpencodeBinToPath", () => {
//#then
expect(env.PATH).toBe("/Users/yeongyu/node_modules/.bin:/usr/bin")
})
it("keeps PATH unchanged when resolved binary path does not exist", () => {
//#given
const env: Record<string, string | undefined> = {
PATH: "/Users/yeongyu/node_modules/.bin:/usr/bin",
}
const resolver = () => "/Users/yeongyu/node_modules/opencode-ai/bin/opencode"
const pathExists = () => false
//#when
prependResolvedOpencodeBinToPath(env, resolver, pathExists)
//#then
expect(env.PATH).toBe("/Users/yeongyu/node_modules/.bin:/usr/bin")
})
})