fix(utility): correct the format of generated hash values and file names (#2012)

Fix a bug in the utility/create-sha-file.mjs module that caused the generated hash values to have an incorrect format and the file names to be undefined. Use the file.name property instead of the file.base property to get the correct file name. Append the hash value before the file name, separated by a tab character, to match the expected format.
This commit is contained in:
Au 2023-09-29 04:49:13 +08:00 committed by GitHub
parent 22e84a2208
commit f6e57fbf0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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 += `${file.base}\t${await hashFile(file)}\n`; s += `${await hashFile(file)}\t${file.name}\n`;
} }
await fs.promises.writeFile(out, s); await fs.promises.writeFile(out, s);
}); });