Browse Source

initialize config in worktree

Dax Raad 3 months ago
parent
commit
2d074f0472
2 changed files with 7 additions and 3 deletions
  1. 1 3
      packages/opencode/src/config/config.ts
  2. 6 0
      packages/opencode/src/worktree/index.ts

+ 1 - 3
packages/opencode/src/config/config.ts

@@ -161,9 +161,7 @@ export namespace Config {
     }
   })
 
-  async function installDependencies(dir: string) {
-    // if (Installation.isLocal()) return
-
+  export async function installDependencies(dir: string) {
     const pkg = path.join(dir, "package.json")
 
     if (!(await Bun.file(pkg).exists())) {

+ 6 - 0
packages/opencode/src/worktree/index.ts

@@ -7,6 +7,7 @@ import { Global } from "../global"
 import { Instance } from "../project/instance"
 import { Project } from "../project/project"
 import { fn } from "../util/fn"
+import { Config } from "@/config/config"
 
 export namespace Worktree {
   export const Info = z
@@ -211,6 +212,11 @@ export namespace Worktree {
       throw new StartCommandFailedError({ message: errorText(ran) || "Worktree start command failed" })
     }
 
+    const opencodeDir = path.join(info.directory, ".opencode")
+    if (await Bun.file(opencodeDir).exists()) {
+      await Config.installDependencies(info.directory)
+    }
+
     return info
   })
 }