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)