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