Unified · Split
| @@ -24,7 +24,7 @@ const fileSystemError = (method: string, cause: unknown) => · 23 unmodified lines | |||
| 24 | _tag: "Unknown", | 24 | _tag: "Unknown", |
| 25 | module: "FileSystem", | 25 | module: "FileSystem", |
| 26 | method, | 26 | method, |
| 27 | description: cause instanceof Error ? cause.message : String(cause), | 27 | description: "FileSystem operation failed", |
| 28 | cause, | 28 | cause, |
| 29 | }); | 29 | }); |
| 30 | 30 | ||
| @@ -54,22 +54,24 @@ const fileSystemLayer = FileSystem.layerNoop({ · 23 unmodified lines | |||
| 54 | const daemonStateLayer = Layer.merge(fileSystemLayer, Path.layer); | 54 | const daemonStateLayer = Layer.merge(fileSystemLayer, Path.layer); |
| 55 | 55 | ||
| 56 | const withDaemonDataDir = <A, E>(effect: Effect.Effect<A, E, FileSystem.FileSystem | Path.Path>) => | 56 | const withDaemonDataDir = <A, E>(effect: Effect.Effect<A, E, FileSystem.FileSystem | Path.Path>) => |
| 57 | Effect.gen(function* () { | 57 | Effect.acquireUseRelease( |
| 58 | const prev = process.env.EXECUTOR_DATA_DIR; | 58 | Effect.sync(() => { |
| 59 | const dir = mkdtempSync(join(tmpdir(), "executor-daemon-state-test-")); | 59 | const prev = process.env.EXECUTOR_DATA_DIR; |
| 60 | process.env.EXECUTOR_DATA_DIR = dir; | 60 | const dir = mkdtempSync(join(tmpdir(), "executor-daemon-state-test-")); |
| 61 | 61 | process.env.EXECUTOR_DATA_DIR = dir; | |
| 62 | try { | 62 | return { dir, prev }; |
| 63 | return yield* effect; | 63 | }), |
| 64 | } finally { | 64 | () => effect, |
| 65 | if (prev === undefined) { | 65 | ({ dir, prev }) => |
| 66 | delete process.env.EXECUTOR_DATA_DIR; | 66 | Effect.sync(() => { |
| 67 | } else { | 67 | if (prev === undefined) { |
| 68 | process.env.EXECUTOR_DATA_DIR = prev; | 68 | delete process.env.EXECUTOR_DATA_DIR; |
| 69 | } | 69 | } else { |
| 70 | rmSync(dir, { recursive: true, force: true }); | 70 | process.env.EXECUTOR_DATA_DIR = prev; |
| 71 | } | 71 | } |
| 72 | }).pipe(Effect.provide(daemonStateLayer)); | 72 | rmSync(dir, { recursive: true, force: true }); |
| 73 | }), | ||
| 74 | ).pipe(Effect.provide(daemonStateLayer)); | ||
| 73 | 75 | ||
| 74 | describe("daemon state", () => { | 76 | describe("daemon state", () => { |
| 75 | it("normalizes local host aliases", () => { | 77 | it("normalizes local host aliases", () => { |