Apply suggestions from code review

Signed-off-by: Max Schmitt <max@schmitt.mx>
This commit is contained in:
Max Schmitt 2024-06-10 11:27:21 +02:00 committed by GitHub
parent ffbcc29470
commit d4d71dda0d
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; const cpus = os.cpus().length;
this.config.workers = Math.max(1, Math.floor(cpus * (parseInt(workers, 10) / 100))); this.config.workers = Math.max(1, Math.floor(cpus * (parseInt(workers, 10) / 100)));
} else { } else {
this.config.workers = resolveWorkers(workers); this.config.workers = parseWorkers(workers);
} }
} else { } else {
this.config.workers = workers; this.config.workers = workers;
@ -223,7 +223,7 @@ function resolveReporters(reporters: Config['reporter'], rootDir: string): Repor
}); });
} }
function resolveWorkers(workers: string) { function parseWorkers(workers: string) {
const parsedWorkers = parseInt(workers, 10); const parsedWorkers = parseInt(workers, 10);
if (isNaN(parsedWorkers)) if (isNaN(parsedWorkers))
throw new Error(`Workers ${workers} must be a number or percentage.`); throw new Error(`Workers ${workers} must be a number or percentage.`);