Skip to content

Commit

Permalink
feat: flush intra-command warnings at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Aug 8, 2024
1 parent 8751944 commit 68cafb3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 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,14 @@ export abstract class SfCommand<T> extends Command {
throw sfCommandError;
}

// eslint-disable-next-line @typescript-eslint/require-await
protected async finally(): Promise<void> {
// flush warnings
this.warningsToFlush.forEach((warning) => {
this.warn(warning);
});
}

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

Expand Down

0 comments on commit 68cafb3

Please sign in to comment.