Skip to content

Commit

Permalink
Merge branch 'fix/print-notarize-error' of github.com:connorgmeehan/n…
Browse files Browse the repository at this point in the history
…otarize into connorgmeehan-fix/print-notarize-error
  • Loading branch information
MarshallOfSound committed May 14, 2024
2 parents ba33a3d + 195de70 commit fe55db4
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions src/notarytool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,41 @@ export async function notarizeAndWaitForNotaryTool(opts: NotaryToolStartOptions)
];

const result = await spawn('xcrun', notarizeArgs);
const parsed = JSON.parse(result.output.trim());

if (result.code !== 0 || !parsed.status || parsed.status !== 'Accepted') {
if (result.code === 0) {
d('notarization success');
return;
}

let parsed: any;
try {
parsed = JSON.parse(result.output.trim());
} catch (err) {
throw new Error(
`Failed to notarize via notarytool. Failed with unexpected result: \n\n${result.output.trim()}`,
);
}

let logOutput: undefined | string;
if (parsed.id) {
try {
if (parsed && parsed.id) {
const logResult = await spawn('xcrun', [
'notarytool',
'log',
parsed.id,
...authorizationArgs(opts),
]);
d('notarization log', logResult.output);
}
const logResult = await spawn('xcrun', [
'notarytool',
'log',
parsed.id,
...authorizationArgs(opts),
]);
d('notarization log', logResult.output);
logOutput = logResult.output;
} catch (e) {
d('failed to pull notarization logs', e);
}
throw new Error(`Failed to notarize via notarytool\n\n${result.output}`);
}
d('notarization success');

let message = `Failed to notarize via notarytool\n\n${result.output}`;
if (logOutput) {
message += `\n\nDiagnostics from notarytool log: ${logOutput}`;
}
throw new Error(message);
});
}

0 comments on commit fe55db4

Please sign in to comment.