From 8366c63c8c7db8beeff14a2965c8318625153fce Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Sat, 19 Jun 2021 20:14:41 +0200 Subject: [PATCH] Refactored manifest creation to use Object.entries --- src/pass.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pass.ts b/src/pass.ts index 2ec7cc9..b2e2451 100644 --- a/src/pass.ts +++ b/src/pass.ts @@ -268,15 +268,17 @@ export class Pass { * and returning the compiled manifest */ const archive = new ZipFile(); - const manifest = Object.keys(finalBundle).reduce( - (acc, current) => { + const manifest = Object.entries(finalBundle).reduce( + (acc, [fileName, buffer]) => { let hashFlow = forge.md.sha1.create(); - hashFlow.update(finalBundle[current].toString("binary")); - archive.addBuffer(finalBundle[current], current); - acc[current] = hashFlow.digest().toHex(); + hashFlow.update(buffer.toString("binary")); + archive.addBuffer(buffer, fileName); - return acc; + return { + ...acc, + [fileName]: hashFlow.digest().toHex(), + }; }, {}, );