From f6491d646e5f66abbb4618bdde7dcc1584fbd3fb Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Thu, 10 Sep 2026 15:37:39 -0500 Subject: [PATCH] Reduce duplication by using `withTmpDir` in `withTmpFile` --- src/util.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/util.ts b/src/util.ts index 574741b83..e397d5029 100644 --- a/src/util.ts +++ b/src/util.ts @@ -95,16 +95,11 @@ export async function withTmpFile( contents: string, body: (filePath: string) => Promise | T, ): Promise { - const tmpDir = fs.mkdtempSync( - path.join(os.tmpdir(), "changetool-validate-test-"), - ); - try { + return withTmpDir(async (tmpDir) => { const filePath = path.join(tmpDir, baseFileName); fs.writeFileSync(filePath, contents); - return await body(filePath); - } finally { - fs.rmSync(tmpDir, { recursive: true, force: true }); - } + return body(filePath); + }); } /**