diff --git a/cli.js b/cli.js index 703dc74..6f34ed4 100755 --- a/cli.js +++ b/cli.js @@ -17,10 +17,19 @@ const cli = meow(` Usage $ create-dmg [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, diff --git a/readme.md b/readme.md index a76857d..a4113e8 100644 --- a/readme.md +++ b/readme.md @@ -30,6 +30,9 @@ $ create-dmg --help Usage $ create-dmg [destination] + Options + --overwrite Overwrite existing DMG with the same name + Examples $ create-dmg 'Lungo.app' $ create-dmg 'Lungo.app' Build/Releases