-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb0b1e1
commit 609d286
Showing
2 changed files
with
32 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { randomUUID } from 'node:crypto'; | ||
import { readFile } from 'node:fs/promises'; | ||
import { tmpdir } from 'node:os'; | ||
import { join } from 'node:path'; | ||
|
||
export function tmpFile(extension: string) { | ||
const dir = tmpdir(); | ||
const fileName = randomUUID(); | ||
const filepath = join(dir, `${fileName}.${extension}`); | ||
|
||
return { | ||
filepath, | ||
read() { | ||
return readFile(filepath, 'utf-8'); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters