From 0755d4852a436ae846249f90f55c3b48a90bfd20 Mon Sep 17 00:00:00 2001 From: Albin Mattsson Date: Sun, 22 Oct 2017 12:27:38 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Only=20clean=20target=20when=20w?= =?UTF-8?q?e=20have=20created=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/appdmg.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/appdmg.js b/lib/appdmg.js index b59b2c1..b52b4e7 100644 --- a/lib/appdmg.js +++ b/lib/appdmg.js @@ -77,14 +77,6 @@ module.exports = exports = function (options) { **/ pipeline.addStep('Looking for target', function (next) { - pipeline.addCleanupStep('unlink-target', 'Removing target image', function (next, hasErrored) { - if (hasErrored) { - fs.unlink(global.target, next) - } else { - next(null) - } - }) - fs.writeFile(global.target, '', { flag: 'wx' }, function (err) { if (err && err.code === 'EEXIST') return next(new Error('Target already exists')) @@ -417,6 +409,14 @@ module.exports = exports = function (options) { **/ pipeline.addStep('Finalizing image', function (next) { + pipeline.addCleanupStep('unlink-target', 'Removing target image', function (next, hasErrored) { + if (hasErrored) { + fs.unlink(global.target, next) + } else { + next(null) + } + }) + var format = global.opts.format || 'UDZO' hdiutil.convert(global.temporaryImagePath, format, global.target, next)