@nodesecure/scanner
Version:
A package API to run a static analysis of your module's dependencies.
24 lines • 673 B
JavaScript
// Import Node.js Dependencies
import fs from "node:fs/promises";
import path from "node:path";
import os from "node:os";
export class TempDirectory {
location;
id;
constructor(location, id) {
this.location = location;
this.id = id;
}
static async create() {
const location = await fs.mkdtemp(path.join(os.tmpdir(), "/"));
return new TempDirectory(location, location.slice(-6));
}
async clear() {
await fs.rm(this.location, { recursive: true, force: true });
return this;
}
async [Symbol.asyncDispose]() {
await this.clear();
}
}
//# sourceMappingURL=TempDirectory.class.js.map