diff --git a/src/notarytool.ts b/src/notarytool.ts index 51ef7d7..3e0386b 100644 --- a/src/notarytool.ts +++ b/src/notarytool.ts @@ -41,6 +41,16 @@ function authorizationArgs(rawOpts: NotaryToolCredentials): string[] { } } +async function getNotarizationLogs(opts: NotaryToolStartOptions, id: string) { + try { + const logResult = await spawn('xcrun', ['notarytool', 'log', id, ...authorizationArgs(opts)]); + d('notarization log', logResult.output); + return logResult.output; + } catch (e) { + d('failed to pull notarization logs', e); + } +} + export async function isNotaryToolAvailable() { const result = await spawn('xcrun', ['--find', 'notarytool']); return result.code === 0; @@ -94,25 +104,14 @@ export async function notarizeAndWaitForNotaryTool(opts: NotaryToolStartOptions) ); } - if (result.code === 0 && parsed.status === 'Accepted') { - d('notarization success'); - return; + let logOutput: undefined | string; + if (typeof parsed.id === 'string') { + logOutput = await getNotarizationLogs(opts, parsed.id); } - let logOutput: undefined | string; - if (parsed.id) { - try { - 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); - } + if (result.code === 0 && parsed.status === 'Accepted') { + d(`notarization success (id: ${parsed.id})`); + return; } let message = `Failed to notarize via notarytool\n\n${result.output}`;