fix: throw error when workers option is not number or percentage (#31210)

This commit is contained in:
Lee Byonghun 2024-06-10 18:27:54 +09:00 committed by GitHub
parent e280d0bd35
commit abaddc01c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -107,7 +107,7 @@ export class FullConfigInternal {
const cpus = os.cpus().length;
this.config.workers = Math.max(1, Math.floor(cpus * (parseInt(workers, 10) / 100)));
} else {
this.config.workers = parseInt(workers, 10);
this.config.workers = parseWorkers(workers);
}
} else {
this.config.workers = workers;
@ -223,6 +223,14 @@ function resolveReporters(reporters: Config['reporter'], rootDir: string): Repor
});
}
function parseWorkers(workers: string) {
const parsedWorkers = parseInt(workers, 10);
if (isNaN(parsedWorkers))
throw new Error(`Workers ${workers} must be a number or percentage.`);
return parsedWorkers;
}
function resolveProjectDependencies(projects: FullProjectInternal[]) {
const teardownSet = new Set<FullProjectInternal>();
for (const project of projects) {