Skip to content

Commit eef939f

Browse files
committed
Re-use existing withTmpDir
1 parent ef0cd9e commit eef939f

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

‎pr-checks/changelog/validate.test.mts‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import assert from "node:assert/strict";
22
import * as fs from "node:fs";
3-
import * as os from "node:os";
43
import * as path from "node:path";
54
import { describe, it } from "node:test";
65

6+
import { withTmpDir } from "../../src/util.js";
7+
78
import {
89
isValidChangenoteContent,
910
isValidChangenoteFileOrDir,
@@ -12,17 +13,6 @@ import {
1213
VALID_CHANGE_NOTE_CATEGORIES,
1314
} from "./validate.mjs";
1415

15-
async function withTmpDir<T>(body: (tmpDir: string) => Promise<T>): Promise<T> {
16-
const tmpDir = fs.mkdtempSync(
17-
path.join(os.tmpdir(), "changetool-validate-test-"),
18-
);
19-
try {
20-
return await body(tmpDir);
21-
} finally {
22-
fs.rmSync(tmpDir, { recursive: true, force: true });
23-
}
24-
}
25-
2616
async function withTmpFile<T>(
2717
baseFileName: string,
2818
contents: string,
@@ -31,7 +21,7 @@ async function withTmpFile<T>(
3121
return await withTmpDir(async (tmpDir) => {
3222
const filePath = path.join(tmpDir, baseFileName);
3323
fs.writeFileSync(filePath, contents);
34-
return await body(filePath);
24+
return body(filePath);
3525
});
3626
}
3727

0 commit comments

Comments
 (0)