Skip to content

Commit

Permalink
πŸ› Only clean target when we have created it
Browse files Browse the repository at this point in the history
  • Loading branch information
cstruct committed Oct 22, 2017
1 parent ee98f7b commit 0755d48
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/appdmg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0755d48

Please sign in to comment.