Skip to content

Commit e6a5bff

Browse files
committed
fix(shell): allow output() to fail with original error
1 parent 0ff1e48 commit e6a5bff

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/@ionic/cli-utils/src/definitions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,13 @@ export interface IShellSpawnOptions extends SpawnOptions {
332332

333333
export interface IShellOutputOptions extends IShellSpawnOptions {
334334
fatalOnError?: boolean;
335+
fatalOnNotFound?: boolean;
335336
showError?: boolean;
336337
}
337338

338339
export interface IShellRunOptions extends IShellOutputOptions {
339340
stream?: NodeJS.WritableStream;
340341
killOnExit?: boolean;
341-
fatalOnNotFound?: boolean;
342342
truncateErrorOutput?: number;
343343
}
344344

packages/@ionic/cli-utils/src/lib/shell.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class Shell implements IShell {
120120
}
121121
}
122122

123-
async output(command: string, args: string[], { fatalOnError = true, showError = true, showCommand = false, ...crossSpawnOptions }: IShellOutputOptions): Promise<string> {
123+
async output(command: string, args: string[], { fatalOnNotFound = true, fatalOnError = true, showError = true, showCommand = false, ...crossSpawnOptions }: IShellOutputOptions): Promise<string> {
124124
const cmd = new ShellCommand(command, args, crossSpawnOptions);
125125

126126
const fullCmd = cmd.bashify();
@@ -134,7 +134,11 @@ export class Shell implements IShell {
134134
return await cmd.output();
135135
} catch (e) {
136136
if (e instanceof ShellCommandError && e.code === ERROR_SHELL_COMMAND_NOT_FOUND) {
137-
throw new FatalException(`Command not found: ${chalk.green(command)}`, 127);
137+
if (fatalOnNotFound) {
138+
throw new FatalException(`Command not found: ${chalk.green(command)}`, 127);
139+
} else {
140+
throw e;
141+
}
138142
}
139143

140144
if (!isExitCodeException(e)) {

0 commit comments

Comments
 (0)