diff options
| author | Dax Raad <[email protected]> | 2025-07-11 21:09:39 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-07-11 21:09:39 -0400 |
| commit | 1254f4813553077509cc74d9e40b3df4181afd37 (patch) | |
| tree | 125aa63c6e59334954863c3d4994a141738ebdf0 | |
| parent | 1729c310d91008e1e908109e61f32a7bbb90f5d9 (diff) | |
| download | opencode-1254f4813553077509cc74d9e40b3df4181afd37.tar.gz opencode-1254f4813553077509cc74d9e40b3df4181afd37.zip | |
fix issue preventing things from working when node_modules or package.json present in ~/
| -rw-r--r-- | packages/opencode/src/bun/index.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/packages/opencode/src/bun/index.ts b/packages/opencode/src/bun/index.ts index fa9cb6e35..0a9ee9ca9 100644 --- a/packages/opencode/src/bun/index.ts +++ b/packages/opencode/src/bun/index.ts @@ -60,11 +60,12 @@ export namespace BunProc { export async function install(pkg: string, version = "latest") { const mod = path.join(Global.Path.cache, "node_modules", pkg) const pkgjson = Bun.file(path.join(Global.Path.cache, "package.json")) - const parsed = await pkgjson.json().catch(() => ({ - dependencies: {}, - })) + const parsed = await pkgjson.json().catch(async () => { + const result = { dependencies: {} } + await Bun.write(pkgjson.name!, JSON.stringify(result, null, 2)) + return result + }) if (parsed.dependencies[pkg] === version) return mod - parsed.dependencies[pkg] = version await BunProc.run( ["add", "--exact", "--cwd", Global.Path.cache, "--registry=https://registry.npmjs.org", pkg + "@" + version], { |
