fix: reject empty removal fixture scans
This commit is contained in:
@@ -78,6 +78,9 @@ export async function runtimeImportGraph(
|
||||
const files = (await filesBelow(root))
|
||||
.filter((file) => /\.(?:[cm]?ts|tsx)$/u.test(file))
|
||||
.map((file) => path.resolve(file));
|
||||
if (files.length === 0) {
|
||||
throw new Error("removal fixture scanned module universe is empty");
|
||||
}
|
||||
const sourceSet = new Set(files);
|
||||
const runtimeRoots = runtimeSourceRoots.map((entry) => path.resolve(root, entry));
|
||||
const imports = new Map<string, readonly string[]>();
|
||||
@@ -124,6 +127,9 @@ export async function removeRuntimeDependentTests(
|
||||
runtimeSourceRoots: readonly string[],
|
||||
): Promise<number> {
|
||||
const graph = await runtimeImportGraph(root, runtimeSourceRoots);
|
||||
if (graph.dependentTests.length === 0) {
|
||||
throw new Error("removal fixture: no runtime-dependent tests discovered");
|
||||
}
|
||||
await Promise.all(graph.dependentTests.map((file) => rm(file, { force: true })));
|
||||
return graph.dependentTests.length;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user