fix(hashFile): use path.basename to get file name (#2209)

Previously, the hashFile function was using file.name to get the file name, which resulted in undefined values in the output file. This commit fixes that by using path.basename(file.full) instead, which correctly extracts the file name from the full path.
This commit is contained in:
Zenvie 2024-02-23 03:58:27 +08:00 committed by GitHub
parent 1a529a9429
commit 20e40c2bad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,7 +24,7 @@ export default (async function (out, archiveFiles) {
const filesToAnalyze = Array.from(new Set(archiveFiles.map(f => f.full))).sort(); const filesToAnalyze = Array.from(new Set(archiveFiles.map(f => f.full))).sort();
let s = ""; let s = "";
for (const file of filesToAnalyze) { for (const file of filesToAnalyze) {
s += `${await hashFile(file)}\t${file.name}\n`; s += `${await hashFile(file)}\t${path.basename(file.full)}\n`;
} }
await fs.promises.writeFile(out, s); await fs.promises.writeFile(out, s);
}); });