Skip to content

Commit

Permalink
Merge pull request #610 from salesforcecli/mdonnalley/flush-warnings
Browse files Browse the repository at this point in the history
feat: flush intra-command warnings at the end
  • Loading branch information
WillieRuemmele authored Aug 9, 2024
2 parents 8751944 + df4b2b7 commit cd5d89d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/sfCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export abstract class SfCommand<T> extends Command {
public configAggregator!: ConfigAggregator;

private warnings: SfCommand.Warning[] = [];
private warningsToFlush: SfCommand.Warning[] = [];
private ux: Ux;
private lifecycle: Lifecycle;

Expand Down Expand Up @@ -330,7 +331,7 @@ export abstract class SfCommand<T> extends Command {
}
// eslint-disable-next-line @typescript-eslint/require-await
this.lifecycle.onWarning(async (warning: string) => {
this.warn(warning);
this.warningsToFlush.push(warning);
});
const options = {
Command: this.ctor,
Expand Down Expand Up @@ -398,6 +399,16 @@ export abstract class SfCommand<T> extends Command {
throw sfCommandError;
}

// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-explicit-any
protected async finally(_: Error | undefined): Promise<any> {
// flush warnings
this.warningsToFlush.forEach((warning) => {
this.warn(warning);
});

return super.finally(_);
}

public abstract run(): Promise<T>;
}

Expand Down

0 comments on commit cd5d89d

Please sign in to comment.