Skip to content

Commit

Permalink
Add --overwrite flag
Browse files Browse the repository at this point in the history
Fixes #15
  • Loading branch information
sindresorhus committed Apr 29, 2018
1 parent 370b6ce commit 1d1a1ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cli.js
Expand Up @@ -17,10 +17,19 @@ const cli = meow(`
Usage
$ create-dmg <app> [destination]
Options
--overwrite Overwrite existing DMG with the same name
Examples
$ create-dmg 'Lungo.app'
$ create-dmg 'Lungo.app' Build/Releases
`);
`, {
flags: {
overwrite: {
type: 'boolean'
}
}
});

let [appPath, destPath] = cli.input;

Expand Down Expand Up @@ -53,6 +62,12 @@ const dmgPath = path.join(destPath, `${appName} ${appInfo.CFBundleShortVersionSt
const ora = new Ora('Creating DMG');
ora.start();

if (cli.flags.overwrite) {
try {
fs.unlinkSync(dmgPath);
} catch (_) {}
}

const ee = appdmg({
target: dmgPath,
basepath: __dirname,
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Expand Up @@ -30,6 +30,9 @@ $ create-dmg --help
Usage
$ create-dmg <app> [destination]
Options
--overwrite Overwrite existing DMG with the same name
Examples
$ create-dmg 'Lungo.app'
$ create-dmg 'Lungo.app' Build/Releases
Expand Down

0 comments on commit 1d1a1ea

Please sign in to comment.