Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b0ada64

Browse files
vsavkinFrozenPandaz
authored andcommittedAug 18, 2020
fix(core): sort files before creating project graph to make stable hashes
1 parent c8eb86d commit b0ada64

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed
 

Diff for: ‎packages/workspace/src/core/file-utils.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -228,26 +228,28 @@ export function readWorkspaceFiles(): FileData[] {
228228
'read workspace files:start',
229229
'read workspace files:end'
230230
);
231+
r.sort((x, y) => x.file.localeCompare(y.file));
231232
return r;
232233
} else {
233-
const files = [];
234-
files.push(...rootWorkspaceFileData());
234+
const r = [];
235+
r.push(...rootWorkspaceFileData());
235236

236237
// Add known workspace files and directories
237-
files.push(...allFilesInDir(appRootPath, false));
238-
files.push(...allFilesInDir(`${appRootPath}/tools`));
238+
r.push(...allFilesInDir(appRootPath, false));
239+
r.push(...allFilesInDir(`${appRootPath}/tools`));
239240
const wl = workspaceLayout();
240-
files.push(...allFilesInDir(`${appRootPath}/${wl.appsDir}`));
241+
r.push(...allFilesInDir(`${appRootPath}/${wl.appsDir}`));
241242
if (wl.appsDir !== wl.libsDir) {
242-
files.push(...allFilesInDir(`${appRootPath}/${wl.libsDir}`));
243+
r.push(...allFilesInDir(`${appRootPath}/${wl.libsDir}`));
243244
}
244245
performance.mark('read workspace files:end');
245246
performance.measure(
246247
'read workspace files',
247248
'read workspace files:start',
248249
'read workspace files:end'
249250
);
250-
return files;
251+
r.sort((x, y) => x.file.localeCompare(y.file));
252+
return r;
251253
}
252254
}
253255

@@ -277,12 +279,10 @@ export function normalizedProjectRoot(p: ProjectGraphNode): string {
277279

278280
export function filesChanged(a: FileData[], b: FileData[]) {
279281
if (a.length !== b.length) return true;
280-
const sortedA = a.sort((x, y) => x.file.localeCompare(y.file));
281-
const sortedB = b.sort((x, y) => x.file.localeCompare(y.file));
282282

283-
for (let i = 0; i < sortedA.length; ++i) {
284-
if (sortedA[i].file !== sortedB[i].file) return true;
285-
if (sortedA[i].hash !== sortedB[i].hash) return true;
283+
for (let i = 0; i < a.length; ++i) {
284+
if (a[i].file !== b[i].file) return true;
285+
if (a[i].hash !== b[i].hash) return true;
286286
}
287287
return false;
288288
}

0 commit comments

Comments
 (0)
Please sign in to comment.