From 5c342449960fc027be84a4520f101675fdffaa92 Mon Sep 17 00:00:00 2001 From: Shawn Date: Fri, 11 Jan 2019 09:39:37 -0600 Subject: [PATCH] Minor execution edjustment --- index.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index a1bc258..cb68d00 100644 --- a/index.js +++ b/index.js @@ -173,15 +173,12 @@ async function unpackDirectory(directory, options = {}) { if(!/^\./.test(header.name)) { const writePath = path.join(directory, header.name); - var fileWriteStream; try { - fileWriteStream = fs.createWriteStream(writePath); - } catch (e) { - // Assume directory may not exist if an error is thrown fs.mkdirSync(path.dirname(writePath), { recursive: true }); - fileWriteStream = fs.createWriteStream(writePath); + } catch (e) { + // Directory exists } - + const fileWriteStream = fs.createWriteStream(writePath); fileWriteStream.write(contents); fileWriteStream.end(); next();