Permalink
Browse files

Improve error message for when the file doesn't exist

  • Loading branch information...
1 parent b998dc8 commit 2e70c00242f6971e6b20eca24091aea39cf39993 @sindresorhus committed Mar 31, 2017
Showing with 14 additions and 1 deletion.
  1. +14 −1 cli.js
View
15 cli.js
@@ -27,7 +27,20 @@ if (cli.input.length === 0) {
}
const appPath = path.resolve(cli.input[0]);
-const appInfo = plist.parse(fs.readFileSync(path.join(appPath, 'Contents/Info.plist'), 'utf8'));
+
+let infoPlist;
+try {
+ infoPlist = fs.readFileSync(path.join(appPath, 'Contents/Info.plist'), 'utf8');
+} catch (err) {
+ if (err.code === 'ENOENT') {
+ console.error(`Could not find "${path.relative(process.cwd(), appPath)}"`);
+ process.exit(1);
+ }
+
+ throw err;
+}
+
+const appInfo = plist.parse(infoPlist);
const appName = appInfo.CFBundleName;
const appIconName = appInfo.CFBundleIconFile.replace(/\.icns/, '');
const dmgPath = `${appName.replace(/ /g, '-')}-${appInfo.CFBundleShortVersionString}.dmg`;

0 comments on commit 2e70c00

Please sign in to comment.