Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Brittle response parsing from notarytool #191

Merged
merged 8 commits into from
May 14, 2024
9 changes: 7 additions & 2 deletions src/notarytool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@ export async function notarizeAndWaitForNotaryTool(opts: NotaryToolStartOptions)
];

const result = await spawn('xcrun', notarizeArgs);
const parsed = JSON.parse(result.output.trim());
let parsed: any;
try {
parsed = JSON.parse(result.output.trim());
} catch (err) {
throw new Error(`Failed to notarize via notarytool\n\nCould not parse output as JSON\n\n${result.output.trim()}`);
}

if (result.code !== 0 || !parsed.status || parsed.status !== 'Accepted') {
if (!parsed.status || parsed.status !== 'Accepted') {
connorgmeehan marked this conversation as resolved.
Show resolved Hide resolved
try {
if (parsed && parsed.id) {
const logResult = await spawn('xcrun', [
Expand Down