diff --git a/src/sfCommand.ts b/src/sfCommand.ts index 72a6a09b..b57056ee 100644 --- a/src/sfCommand.ts +++ b/src/sfCommand.ts @@ -153,6 +153,7 @@ export abstract class SfCommand extends Command { public configAggregator!: ConfigAggregator; private warnings: SfCommand.Warning[] = []; + private warningsToFlush: SfCommand.Warning[] = []; private ux: Ux; private lifecycle: Lifecycle; @@ -330,7 +331,7 @@ export abstract class SfCommand 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, @@ -398,6 +399,16 @@ export abstract class SfCommand extends Command { throw sfCommandError; } + // eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-explicit-any + protected async finally(_: Error | undefined): Promise { + // flush warnings + this.warningsToFlush.forEach((warning) => { + this.warn(warning); + }); + + return super.finally(_); + } + public abstract run(): Promise; }