From 6d4a948dd8d229101f2b973c45f320e4bf04ebab Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Sun, 11 Feb 2024 19:25:52 +0100 Subject: [PATCH] minor refactor --- src/bin/downloadAndUnzip.ts | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/bin/downloadAndUnzip.ts b/src/bin/downloadAndUnzip.ts index 0a738bbf..e11a4c1e 100644 --- a/src/bin/downloadAndUnzip.ts +++ b/src/bin/downloadAndUnzip.ts @@ -30,19 +30,23 @@ export async function downloadAndUnzip(params: { }) { const { url, destDirPath, specificDirsToExtract, preCacheTransform, buildOptions } = params; - const zipFileBasename = generateFileNameFromURL({ - url, - "preCacheTransform": - preCacheTransform === undefined - ? undefined - : { - "actionCacheId": preCacheTransform.actionCacheId, - "actionFootprint": preCacheTransform.action.toString() - } - }); + const { extractDirPath, zipFilePath } = (() => { + const zipFileBasenameWithoutExt = generateFileNameFromURL({ + url, + "preCacheTransform": + preCacheTransform === undefined + ? undefined + : { + "actionCacheId": preCacheTransform.actionCacheId, + "actionFootprint": preCacheTransform.action.toString() + } + }); - const zipFilePath = pathJoin(buildOptions.cacheDirPath, `${zipFileBasename}.zip`); - const extractDirPath = pathJoin(buildOptions.cacheDirPath, `tmp_unzip_${zipFileBasename}`); + const zipFilePath = pathJoin(buildOptions.cacheDirPath, `${zipFileBasenameWithoutExt}.zip`); + const extractDirPath = pathJoin(buildOptions.cacheDirPath, `tmp_unzip_${zipFileBasenameWithoutExt}`); + + return { zipFilePath, extractDirPath }; + })(); download_zip_and_transform: { if (await existsAsync(zipFilePath)) {