fs: Limit random tmp suffix to 8 digits

This commit is contained in:
Danny Lin 2021-12-16 19:06:33 -08:00
parent ce64f175c4
commit 954374861d

View file

@ -37,7 +37,7 @@ export async function exists(path: string) {
export async function withTempDir<Return>(callback: (tmp: TempState) => Promise<Return>) {
let tmp = os.tmpdir()
let rand = `${Math.random()}`.slice(2)
let rand = `${Math.random()}`.slice(2, 10)
let dir = `${tmp}/${TMP_PREFIX}${rand}`
await fs.rm(dir, { force: true, recursive: true })