From a5eed7297b4d39d665d66be99728cf19f3b8d1cb Mon Sep 17 00:00:00 2001 From: rh389 Date: Tue, 24 Oct 2017 13:05:42 +0100 Subject: [PATCH] Tidy up shouldSkipAcquire, skip manifest check on --force --- scripts/download-realm.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/download-realm.js b/scripts/download-realm.js index 0361ce86..b962af2c 100644 --- a/scripts/download-realm.js +++ b/scripts/download-realm.js @@ -205,24 +205,30 @@ function readManifest(target) { try { return ini.parse(fs.readFileSync(path.resolve(target, MANIFEST_FILENAME), 'utf8')); } catch (e) { - return false; + return null; } } function shouldSkipAcquire(target, desiredManifest, force) { + if (force) { + console.log('Skipping manifest check as --force is enabled'); + return false; + } + const existingManifest = readManifest(target); if (!existingManifest) { console.log('No manifest at the target, proceeding.'); - } else if (!Object.keys(desiredManifest).every(key => existingManifest[key] === desiredManifest[key])) { - console.log('Target has is non-empty but has a different manifest, overwriting.'); - } else if (force) { - console.log('Target has a matching manifest but download forced.'); - } else { - console.log('Matching manifest already exists at target - nothing to do (use --force to override)'); - return true; + return false; } - return false; + + if (!Object.keys(desiredManifest).every(key => existingManifest[key] === desiredManifest[key])) { + console.log('Target directory has a differing manifest, overwriting.'); + return false; + } + + console.log('Matching manifest already exists at target - nothing to do (use --force to override)'); + return true; } const optionDefinitions = [