Skip to content

Commit 20ad765

Browse files
authored
Update the logic to identify a failed process (#4133)
1 parent b51535d commit 20ad765

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

extension/src/cli/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export class Cli extends Disposable implements ICli {
193193
{
194194
...baseEvent,
195195
duration,
196-
errorOutput: all || cliError.stderr,
196+
errorOutput: all || cliError.stderr || error.message,
197197
exitCode: cliError.exitCode
198198
},
199199
this.processCompleted

extension/src/cli/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ export const notifyOutput = (
2323
}
2424

2525
export const notifyCompleted = (
26-
{ command, pid, cwd, duration, exitCode, errorOutput: stderr }: CliResult,
26+
{ command, pid, cwd, duration, exitCode, errorOutput }: CliResult,
2727
processCompleted: EventEmitter<CliResult>
2828
): void =>
2929
processCompleted.fire({
3030
command,
3131
cwd,
3232
duration,
33-
errorOutput: stderr?.replace(/\n+/g, '\n'),
33+
errorOutput: errorOutput?.replace(/\n+/g, '\n'),
3434
exitCode,
3535
pid
3636
})

extension/src/vscode/outputChannel.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ export class OutputChannel extends Disposable {
4242
this.dispose.track(
4343
cli.onDidCompleteProcess(
4444
({ command, duration, exitCode, pid, errorOutput }) => {
45-
const processStatus =
46-
exitCode && errorOutput
47-
? ProcessStatus.FAILED
48-
: ProcessStatus.COMPLETED
45+
const processStatus = this.assumeFailed(exitCode, errorOutput)
46+
? ProcessStatus.FAILED
47+
: ProcessStatus.COMPLETED
4948

5049
const baseOutput = this.getBaseOutput(pid, command, processStatus)
5150
const completionOutput = this.getCompletionOutput(
@@ -86,10 +85,17 @@ export class OutputChannel extends Disposable {
8685

8786
completionOutput += ` (${duration}ms)`
8887

89-
if (exitCode && errorOutput) {
88+
if (this.assumeFailed(exitCode, errorOutput)) {
9089
completionOutput += `\n${errorOutput}`
9190
}
9291

9392
return completionOutput
9493
}
94+
95+
private assumeFailed(
96+
exitCode: number | null,
97+
errorOutput: string | undefined
98+
): errorOutput is string {
99+
return exitCode !== 0 && !!errorOutput
100+
}
95101
}

0 commit comments

Comments
 (0)