Skip to content

Commit 17d78c0

Browse files
vsavkinFrozenPandaz
authored andcommittedAug 19, 2020
fix(core): explicitly store workspace files instead of deriving them from hashes
1 parent 4f22832 commit 17d78c0

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed
 

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ export function readWorkspaceFiles(): FileData[] {
219219

220220
if (defaultFileHasher.usesGitForHashing) {
221221
const ignoredGlobs = getIgnoredGlobs();
222-
const r = defaultFileHasher
223-
.allFiles()
222+
const r = defaultFileHasher.workspaceFiles
224223
.filter((f) => !ignoredGlobs.ignores(f))
225224
.map((f) => getFileData(`${appRootPath}/${f}`));
226225
performance.mark('read workspace files:end');

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function extractNameAndVersion(content: string): string {
2020

2121
export class FileHasher {
2222
fileHashes: { [path: string]: string } = {};
23+
workspaceFiles = [];
2324
usesGitForHashing = false;
2425

2526
constructor(private readonly hashing: HashingImp) {
@@ -29,6 +30,7 @@ export class FileHasher {
2930
init() {
3031
performance.mark('init hashing:start');
3132
this.fileHashes = {};
33+
this.workspaceFiles = [];
3234
this.getHashesFromGit();
3335
this.usesGitForHashing = Object.keys(this.fileHashes).length > 0;
3436
performance.mark('init hashing:end');
@@ -49,14 +51,15 @@ export class FileHasher {
4951
return this.fileHashes[relativePath];
5052
}
5153

52-
allFiles() {
53-
return Object.keys(this.fileHashes);
54-
}
55-
5654
private getHashesFromGit() {
5755
const sliceIndex = appRootPath.length + 1;
5856
getFileHashes(appRootPath).forEach((hash, filename) => {
5957
this.fileHashes[filename.substr(sliceIndex)] = hash;
58+
/**
59+
* we have to store it separately because fileHashes can be modified
60+
* later on and can contain files that do not exist in the workspace
61+
*/
62+
this.workspaceFiles.push(filename.substr(sliceIndex));
6063
});
6164
}
6265

0 commit comments

Comments
 (0)