Skip to content

Commit 695dc5b

Browse files
committed
feat: add tempDir
1 parent eb7fca7 commit 695dc5b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/utils/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";
3+
4+
test("tempDir", async () => {
5+
await using dir = await tempDir();
6+
expect(dir).toBeDefined();
7+
expect(dir.path).toBeDefined();
8+
});

lib/utils/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-web-"));
8+
}

0 commit comments

Comments
 (0)