Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions packages/hasher/src/FileHasher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class FileHasher {
const stats = stat(files, { cwd: this.options.root }) ?? {};

for (const file of files) {
const stat = stats[file];
const stat = stats[file] || { mtime: 0n, size: 0 };

const info = this.#store[file];
if (info && stat.mtime === info.mtime && stat.size == info.size) {
Expand All @@ -107,12 +107,24 @@ export class FileHasher {
const updatedHashes = fastHash(updatedFiles, { cwd: this.options.root, concurrency: 4 }) ?? {};

for (const [file, hash] of Object.entries(updatedHashes)) {
const stat = fs.statSync(path.join(this.options.root, file), { bigint: true });
this.#store[file] = {
mtime: stat.mtimeMs,
size: Number(stat.size),
hash: hash ?? "",
};
try {
const stat = fs.statSync(path.join(this.options.root, file), { bigint: true });
this.#store[file] = {
mtime: stat.mtimeMs,
size: Number(stat.size),
hash: hash ?? "",
};
} catch (e: any) {
if (e.code === "ENOENT") {
this.#store[file] = {
mtime: 0n,
size: 0,
hash: hash ?? "",
};
} else {
throw e;
}
}
hashes[file] = hash ?? "";
}

Expand Down