Continue ESM transform
This commit is contained in:
parent
b8205a63aa
commit
36835216f5
44 changed files with 1939 additions and 502 deletions
|
@ -1,29 +1,29 @@
|
|||
import fs from "fs";
|
||||
import crypto from "crypto";
|
||||
function hashFile(path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let sum = crypto.createHash("sha256");
|
||||
let fileStream = fs.createReadStream(path);
|
||||
fileStream.on("error", err => {
|
||||
return reject(err);
|
||||
});
|
||||
fileStream.on("data", chunk => {
|
||||
try {
|
||||
sum.update(chunk);
|
||||
}
|
||||
catch (ex) {
|
||||
return reject(ex);
|
||||
}
|
||||
});
|
||||
fileStream.on("end", () => {
|
||||
return resolve(sum.digest("hex"));
|
||||
});
|
||||
});
|
||||
}
|
||||
export default (async function (out, archiveFiles) {
|
||||
let s = "";
|
||||
for (const file of archiveFiles) {
|
||||
s += `${file.base}\t${await hashFile(file.full)}\n`;
|
||||
}
|
||||
await fs.promises.writeFile(out, s);
|
||||
});
|
||||
import crypto from "crypto";
|
||||
import fs from "fs";
|
||||
|
||||
function hashFile(path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let sum = crypto.createHash("sha256");
|
||||
let fileStream = fs.createReadStream(path);
|
||||
fileStream.on("error", err => {
|
||||
return reject(err);
|
||||
});
|
||||
fileStream.on("data", chunk => {
|
||||
try {
|
||||
sum.update(chunk);
|
||||
} catch (ex) {
|
||||
return reject(ex);
|
||||
}
|
||||
});
|
||||
fileStream.on("end", () => {
|
||||
return resolve(sum.digest("hex"));
|
||||
});
|
||||
});
|
||||
}
|
||||
export default (async function (out, archiveFiles) {
|
||||
let s = "";
|
||||
for (const file of archiveFiles) {
|
||||
s += `${file.base}\t${await hashFile(file.full)}\n`;
|
||||
}
|
||||
await fs.promises.writeFile(out, s);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue