Skip to content

Commit ddd1bc5

Browse files
committed
feat: add tempDir using AsyncDisposable
Requires Node >=24.4
1 parent 21548c0 commit ddd1bc5

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"dist"
5252
],
5353
"engines": {
54-
"node": ">=20"
54+
"node": ">=24.4"
5555
},
5656
"scripts": {
5757
"check": "tsc --noEmit",

src/temp-dir.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { expect, test } from "vitest";
2+
import { tempDir } from "./temp-dir.ts";
3+
4+
test("tempDir", async () => {
5+
await using dir = await tempDir();
6+
expect(dir).toBeDefined();
7+
expect(dir.path).toBeDefined();
8+
});

src/temp-dir.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { mkdtempDisposable, realpath } from "node:fs/promises";
2+
import { tmpdir } from "node:os";
3+
import { join } from "node:path";
4+
5+
export async function tempDir() {
6+
const realTmpDir = await realpath(tmpdir());
7+
return await mkdtempDisposable(join(realTmpDir, "jsdocs-io-extractor-"));
8+
}

0 commit comments

Comments
 (0)