Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ export const layer = Layer.effect(
const hasIgnore = yield* fs.existsSafe(gitignore)
if (!hasIgnore) {
yield* fs
.writeFileString(
.writeWithDirs(
gitignore,
["node_modules", "package.json", "package-lock.json", "bun.lock", ".gitignore"].join("\n"),
Buffer.from(["node_modules", "package.json", "package-lock.json", "bun.lock", ".gitignore"].join("\n")),
)
.pipe(
Effect.catchIf(
Expand Down
17 changes: 17 additions & 0 deletions packages/opencode/test/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,23 @@ it.effect("installs dependencies in writable OPENCODE_CONFIG_DIR", () =>
}).pipe(Effect.provide(testInstanceStoreLayer), Effect.provide(CrossSpawnSpawner.defaultLayer)),
)

it.effect("creates .gitignore in OPENCODE_CONFIG_DIR when directory does not yet exist", () =>
Effect.gen(function* () {
const dir = yield* tmpdirScoped()
const configDir = path.join(dir, "nonexistent-config-dir")

yield* withProcessEnv(
"OPENCODE_CONFIG_DIR",
configDir,
Config.Service.use((svc) => svc.get().pipe(Effect.andThen(svc.waitForDependencies()))).pipe(
provideInstanceEffect(dir),
),
)

expect(yield* FSUtil.use.readFileString(path.join(configDir, ".gitignore"))).toContain("node_modules")
}).pipe(Effect.provide(testInstanceStoreLayer), Effect.provide(CrossSpawnSpawner.defaultLayer)),
)

// Note: deduplication and serialization of npm installs is now handled by the
// core Npm.Service (via EffectFlock). Those behaviors are tested in the core
// package's npm tests, not here.
Expand Down
Loading