From 7098a700aa0904d72a335ca3f90d64a079e35e20 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Thu, 25 Jan 2018 22:12:46 -0800 Subject: [PATCH] Fix overwrite when default platform/arch are used Fixes #792. --- index.js | 3 ++- test/basic.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 127b1940..2523f60c 100644 --- a/index.js +++ b/index.js @@ -63,6 +63,7 @@ class Packager { } overwriteAndCreateApp (outDir, comboOpts, zipPath) { + debug(`Removing ${outDir} due to setting overwrite: true`) return fs.remove(outDir) .then(() => this.createApp(comboOpts, zipPath)) } @@ -94,7 +95,7 @@ class Packager { } checkOverwrite (comboOpts, zipPath) { - const finalPath = common.generateFinalPath(this.opts) + const finalPath = common.generateFinalPath(comboOpts) return fs.pathExists(finalPath) .then(exists => { if (exists) { diff --git a/test/basic.js b/test/basic.js index 40eba2cd..62335407 100644 --- a/test/basic.js +++ b/test/basic.js @@ -195,6 +195,21 @@ util.testSinglePlatform('overwrite test', (t, opts) => { .then(exists => t.false(exists, 'The output directory should be regenerated when overwrite is true')) }) +util.testSinglePlatform('overwrite test sans platform/arch set', (t, opts) => { + delete opts.platfrom + delete opts.arch + opts.dir = util.fixtureSubdir('basic') + opts.overwrite = true + + return packager(opts) + .then(paths => fs.pathExists(paths[0])) + .then(exists => { + t.true(exists, 'The output directory exists') + return packager(opts) + }).then(paths => fs.pathExists(paths[0])) + .then(exists => t.true(exists, 'The output directory exists')) +}) + util.testSinglePlatform('tmpdir test', (t, opts) => { opts.name = 'tmpdirTest' opts.dir = path.join(__dirname, 'fixtures', 'basic')