Skip to content

Commit bce5811

Browse files
committed
Simplify getting file checksum
1 parent b10a2df commit bce5811

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/extension/utils/runtime.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -489,16 +489,8 @@ export class Runnable extends EventEmitter {
489489
}
490490

491491
export async function getFileChecksum(file: string): Promise<string> {
492-
return new Promise((resolve, reject) => {
493-
const hash = crypto.createHash("md5");
494-
const stream = fs.createReadStream(file, { encoding: "utf8" });
495-
stream.once("error", (err) => reject(err));
496-
stream.once("end", () => {
497-
hash.end();
498-
resolve(hash.digest("hex"));
499-
});
500-
stream.pipe(hash);
501-
});
492+
const content = await fs.promises.readFile(file);
493+
return crypto.createHash("md5").update(content).digest("hex");
502494
}
503495

504496
async function doCompile(

0 commit comments

Comments
 (0)