Skip to content

Commit 68cafb3

Browse files
committed
feat: flush intra-command warnings at the end
1 parent 8751944 commit 68cafb3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/sfCommand.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export abstract class SfCommand<T> extends Command {
153153
public configAggregator!: ConfigAggregator;
154154

155155
private warnings: SfCommand.Warning[] = [];
156+
private warningsToFlush: SfCommand.Warning[] = [];
156157
private ux: Ux;
157158
private lifecycle: Lifecycle;
158159

@@ -330,7 +331,7 @@ export abstract class SfCommand<T> extends Command {
330331
}
331332
// eslint-disable-next-line @typescript-eslint/require-await
332333
this.lifecycle.onWarning(async (warning: string) => {
333-
this.warn(warning);
334+
this.warningsToFlush.push(warning);
334335
});
335336
const options = {
336337
Command: this.ctor,
@@ -398,6 +399,14 @@ export abstract class SfCommand<T> extends Command {
398399
throw sfCommandError;
399400
}
400401

402+
// eslint-disable-next-line @typescript-eslint/require-await
403+
protected async finally(): Promise<void> {
404+
// flush warnings
405+
this.warningsToFlush.forEach((warning) => {
406+
this.warn(warning);
407+
});
408+
}
409+
401410
public abstract run(): Promise<T>;
402411
}
403412

0 commit comments

Comments
 (0)