Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 Add overwrite option #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ the JSON file's path.
+ `background` (string, optional) - Path to your background
+ `background-color` (string, optional) - Background color (accepts css colors)
+ `icon-size` (number, optional) - Size of all the icons inside the DMG
+ `overwrite-target` (boolean, optional) - Overwrite target if it exists
+ `window` (object, optional) - Window options
+ `position` (object, optional) - Position when opened
+ `x` (number, required) - X position relative to left of the screen
Expand Down
40 changes: 20 additions & 20 deletions lib/appdmg.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,6 @@ module.exports = exports = function (options) {

var pipeline = new Pipeline()

/**
**
**/

pipeline.addStep('Looking for target', function (next) {
fs.writeFile(global.target, '', { flag: 'wx' }, function (err) {
if (err && err.code === 'EEXIST') return next(new Error('Target already exists'))
if (err) return next(err)

pipeline.addCleanupStep('unlink-target', 'Removing target image', function (next, hasErrored) {
if (hasErrored) {
fs.unlink(global.target, next)
} else {
next(null)
}
})
next(null)
})
})

/**
**
**/
Expand Down Expand Up @@ -148,6 +128,26 @@ module.exports = exports = function (options) {
next(new Error(message))
})

/**
**
**/

pipeline.addStep('Looking for target', function (next) {
fs.writeFile(global.target, '', { flag: global.opts['overwrite-target'] ? 'w' : 'wx' }, function (err) {
if (err && err.code === 'EEXIST') return next(new Error('Target already exists'))
if (err) return next(err)

pipeline.addCleanupStep('unlink-target', 'Removing target image', function (next, hasErrored) {
if (hasErrored) {
fs.unlink(global.target, next)
} else {
next(null)
}
})
next(null)
})
})

/**
**
**/
Expand Down
3 changes: 3 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"icon-size": {
"type": "integer"
},
"overwrite-target": {
"type": "boolean"
},
"window": {
"type": "object",
"properties": {
Expand Down