import fs from "node:fs"; import fsPromises from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { afterEach } from "vitest";
export function createScriptTestHarness() { const tempDirs: string[] = [];
afterEach(() => { while (tempDirs.length > 0) { const dir = tempDirs.pop(); if (dir) {
fs.rmSync(dir, { recursive: true, force: true });
}
}
});
function createTempDir(prefix: string): string { const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
tempDirs.push(dir); return dir;
}
async function createTempDirAsync(prefix: string): Promise<string> { const dir = await fsPromises.mkdtemp(path.join(os.tmpdir(), prefix));
tempDirs.push(dir); return dir;
}
function trackTempDir(dir: string): string {
tempDirs.push(dir); return dir;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.