diff --git a/packages/workspace/src/core/file-utils.ts b/packages/workspace/src/core/file-utils.ts index fada7dc0bdcd2..799085fc58f91 100644 --- a/packages/workspace/src/core/file-utils.ts +++ b/packages/workspace/src/core/file-utils.ts @@ -228,18 +228,19 @@ export function readWorkspaceFiles(): FileData[] { 'read workspace files:start', 'read workspace files:end' ); + r.sort((x, y) => x.file.localeCompare(y.file)); return r; } else { - const files = []; - files.push(...rootWorkspaceFileData()); + const r = []; + r.push(...rootWorkspaceFileData()); // Add known workspace files and directories - files.push(...allFilesInDir(appRootPath, false)); - files.push(...allFilesInDir(`${appRootPath}/tools`)); + r.push(...allFilesInDir(appRootPath, false)); + r.push(...allFilesInDir(`${appRootPath}/tools`)); const wl = workspaceLayout(); - files.push(...allFilesInDir(`${appRootPath}/${wl.appsDir}`)); + r.push(...allFilesInDir(`${appRootPath}/${wl.appsDir}`)); if (wl.appsDir !== wl.libsDir) { - files.push(...allFilesInDir(`${appRootPath}/${wl.libsDir}`)); + r.push(...allFilesInDir(`${appRootPath}/${wl.libsDir}`)); } performance.mark('read workspace files:end'); performance.measure( @@ -247,7 +248,8 @@ export function readWorkspaceFiles(): FileData[] { 'read workspace files:start', 'read workspace files:end' ); - return files; + r.sort((x, y) => x.file.localeCompare(y.file)); + return r; } } @@ -277,12 +279,10 @@ export function normalizedProjectRoot(p: ProjectGraphNode): string { export function filesChanged(a: FileData[], b: FileData[]) { if (a.length !== b.length) return true; - const sortedA = a.sort((x, y) => x.file.localeCompare(y.file)); - const sortedB = b.sort((x, y) => x.file.localeCompare(y.file)); - for (let i = 0; i < sortedA.length; ++i) { - if (sortedA[i].file !== sortedB[i].file) return true; - if (sortedA[i].hash !== sortedB[i].hash) return true; + for (let i = 0; i < a.length; ++i) { + if (a[i].file !== b[i].file) return true; + if (a[i].hash !== b[i].hash) return true; } return false; }