Add --overwrite flag

Fixes #15
This commit is contained in:
Sindre Sorhus 2018-04-29 20:58:01 +07:00
parent 370b6ceab5
commit 1d1a1eaa27
2 changed files with 19 additions and 1 deletions

17
cli.js
View File

@ -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;
@ -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,

View File

@ -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