Skip to content

Commit 759066b

Browse files
authored
Merge pull request #562 from futureware-tech/logging
Print stdout/stderr even if the command fails
2 parents f6578e3 + f3c3538 commit 759066b

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

src/xcrun.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,25 @@ export async function simctl(action: string, udid: string): Promise<void> {
6262
async function xcrun(tail: string): Promise<string> {
6363
const command = `xcrun ${tail}`
6464
core.info(`$ ${command}`)
65-
const {stdout, stderr} = await execAsync(command)
66-
if (stderr) {
67-
core.warning(`Errors or warnings in the output of ${command}`)
68-
core.startGroup(`[stderr] ${command}`)
69-
core.warning(stderr)
70-
core.endGroup()
71-
}
72-
if (core.isDebug()) {
73-
core.startGroup(`[stdout] ${command}`)
74-
core.debug(stdout)
75-
core.endGroup()
65+
66+
let res: {stdout?: string; stderr?: string} | undefined
67+
try {
68+
res = await execAsync(command)
69+
return res.stdout || ''
70+
} catch (e) {
71+
res = e as {stdout?: string; stderr?: string}
72+
throw e
73+
} finally {
74+
if (res?.stderr) {
75+
core.warning(`Errors or warnings in the output of ${command}`)
76+
core.startGroup(`[stderr] ${command}`)
77+
core.warning(res.stderr)
78+
core.endGroup()
79+
}
80+
if (res?.stdout && core.isDebug()) {
81+
core.startGroup(`[stdout] ${command}`)
82+
core.debug(res.stdout)
83+
core.endGroup()
84+
}
7685
}
77-
return stdout
7886
}

0 commit comments

Comments
 (0)