mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
23 lines
525 B
JavaScript
23 lines
525 B
JavaScript
import { existsSync, mkdirSync, promises } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
const count = 1024 * 12;
|
|
|
|
var queue = new Array(count);
|
|
var paths = new Array(count);
|
|
for (let i = 0; i < count; i++) {
|
|
const path = `${tmpdir()}/${Date.now()}.rm.dir${i}`;
|
|
try {
|
|
mkdirSync(path);
|
|
} catch (e) {}
|
|
paths[i] = path;
|
|
queue[i] = promises.rmdir(path);
|
|
}
|
|
|
|
await Promise.all(queue);
|
|
|
|
for (let i = 0; i < count; i++) {
|
|
if (existsSync(paths[i])) {
|
|
throw new Error(`Path ${paths[i]} was not removed`);
|
|
}
|
|
}
|