Skip to content

Commit 432f6cf

Browse files
fix(cli): do not lint the same project in multiple workers (#67)
1 parent 6921ee6 commit 432f6cf

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

packages/cli/index.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if (process.argv.includes('--threads')) {
4040
}
4141

4242
class Project {
43-
workers: ReturnType<typeof worker.create>[] = [];
43+
worker: ReturnType<typeof worker.create> | undefined;
4444
fileNames: string[] = [];
4545
options: ts.CompilerOptions = {};
4646
configFile: string | undefined;
@@ -100,7 +100,7 @@ class Project {
100100
}
101101

102102
const originalFileNamesLength = this.fileNames.length;
103-
103+
104104
if (filesFilter.size) {
105105
this.fileNames = this.fileNames.filter(f => filesFilter.has(f));
106106
if (!this.fileNames.length) {
@@ -412,17 +412,12 @@ class Project {
412412
if (!unfinishedProjects.length) {
413413
return;
414414
}
415-
// Select a project that has not has a worker yet
416-
let project = unfinishedProjects.find(project => !project.workers.length);
415+
// Select a project that does not have a worker yet
416+
const project = unfinishedProjects.find(project => !project.worker);
417417
if (!project) {
418-
// Choose a project with the most files left per worker
419-
project = unfinishedProjects.sort((a, b) => {
420-
const aFilesPerWorker = (a.fileNames.length - a.currentFileIndex) / a.workers.length;
421-
const bFilesPerWorker = (b.fileNames.length - b.currentFileIndex) / b.workers.length;
422-
return bFilesPerWorker - aFilesPerWorker;
423-
})[0];
418+
return;
424419
}
425-
project.workers.push(linterWorker);
420+
project.worker = linterWorker;
426421

427422
const setupSuccess = await linterWorker.setup(
428423
project.tsconfig,

0 commit comments

Comments
 (0)