From 48f0d56cde5cb57a4b178c1ee67759a8bd8d6c3a Mon Sep 17 00:00:00 2001 From: Ian Pascoe Date: Wed, 11 Nov 2026 14:57:08 -0500 Subject: [PATCH] test: remove the temporary directories tests create --- infra/src/github-app.test.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/infra/src/github-app.test.ts b/infra/src/github-app.test.ts index 620b5b21..8cc6faae 100644 --- a/infra/src/github-app.test.ts +++ b/infra/src/github-app.test.ts @@ -1,14 +1,23 @@ // @effect-diagnostics nodeBuiltinImport:off -- the dev.env is read back by a real bash. import { execFileSync } from "node:child_process"; -import { mkdtempSync, writeFileSync } from "node:fs"; +import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { describe, expect, it } from "vitest"; +import { afterEach, describe, expect, it } from "vitest"; import { withDevEnvValues } from "./github-app.ts"; +const roots: string[] = []; + +afterEach(() => { + for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); +}); + /** What `set -a; . file` gives bash for `name`, as a deploy from a workstation loads dev.env. */ const sourced = (text: string, name: string): string => { - const file = join(mkdtempSync(join(tmpdir(), "dev-env-")), "dev.env"); + const root = mkdtempSync(join(tmpdir(), "dev-env-")); + const file = join(root, "dev.env"); + + roots.push(root); writeFileSync(file, text);