diff options
| author | Kit Langton <[email protected]> | 2026-05-03 11:21:34 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-05-03 15:21:34 +0000 |
| commit | 13ac849db5c378ed04d02d644006f01e70db31b6 (patch) | |
| tree | e1932f0063caa2aee3968aaadb57c7c26d1f0a8d /packages/core/src | |
| parent | 8694c5b68fc57e7e1bb8129b72b08e128dce9f17 (diff) | |
| download | opencode-13ac849db5c378ed04d02d644006f01e70db31b6.tar.gz opencode-13ac849db5c378ed04d02d644006f01e70db31b6.zip | |
refactor(config+core): drop ConfigPaths.readFile, add AppFileSystem.readFileStringSafe, flatten TuiConfig.loadState (#25602)
Diffstat (limited to 'packages/core/src')
| -rw-r--r-- | packages/core/src/filesystem.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/packages/core/src/filesystem.ts b/packages/core/src/filesystem.ts index 44346be8f..8a1cc3a08 100644 --- a/packages/core/src/filesystem.ts +++ b/packages/core/src/filesystem.ts @@ -24,6 +24,7 @@ export namespace AppFileSystem { readonly isDir: (path: string) => Effect.Effect<boolean> readonly isFile: (path: string) => Effect.Effect<boolean> readonly existsSafe: (path: string) => Effect.Effect<boolean> + readonly readFileStringSafe: (path: string) => Effect.Effect<string | undefined, Error> readonly readJson: (path: string) => Effect.Effect<unknown, Error> readonly writeJson: (path: string, data: unknown, mode?: number) => Effect.Effect<void, Error> readonly ensureDir: (path: string) => Effect.Effect<void, Error> @@ -47,6 +48,12 @@ export namespace AppFileSystem { return yield* fs.exists(path).pipe(Effect.orElseSucceed(() => false)) }) + const readFileStringSafe = Effect.fn("FileSystem.readFileStringSafe")(function* (path: string) { + return yield* fs + .readFileString(path) + .pipe(Effect.catchReason("PlatformError", "NotFound", () => Effect.succeed(undefined))) + }) + const isDir = Effect.fn("FileSystem.isDir")(function* (path: string) { const info = yield* fs.stat(path).pipe(Effect.catch(() => Effect.void)) return info?.type === "Directory" @@ -163,6 +170,7 @@ export namespace AppFileSystem { return Service.of({ ...fs, existsSafe, + readFileStringSafe, isDir, isFile, readDirectoryEntries, |
