Skip to content

Commit

Permalink
Improve error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Aug 21, 2023
1 parent 64eaaca commit c4af342
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@ async function init() {
throw error;
}

await execa('/usr/bin/codesign', ['--sign', identity, dmgPath]);
try {
await execa('/usr/bin/codesign', ['--sign', identity, dmgPath]);
} catch (error) {
ora.fail(`Code signing failed. The DMG is fine, just not code signed.\n${error.stderr?.trim() ?? error}`);
process.exit(2);
}

const {stderr} = await execa('/usr/bin/codesign', [dmgPath, '--display', '--verbose=2']);

const match = /^Authority=(.*)$/m.exec(stderr);
Expand All @@ -198,7 +204,7 @@ async function init() {
ora.info(`Code signing identity: ${match[1]}`).start();
ora.succeed(`Created “${dmgFilename}”`);
} catch (error) {
ora.fail(`Code signing failed. The DMG is fine, just not code signed.\n${Object.prototype.hasOwnProperty.call(error, 'stderr') ? error.stderr.trim() : error}`);
ora.fail(`${error.stderr?.trim() ?? error}`);
process.exit(2);
}
});
Expand Down

0 comments on commit c4af342

Please sign in to comment.