File tree Expand file tree Collapse file tree 2 files changed +19
-17
lines changed
packages/angular_devkit/build_angular/src Expand file tree Collapse file tree 2 files changed +19
-17
lines changed Original file line number Diff line number Diff line change 88
99import * as ora from 'ora' ;
1010import { colors } from './color' ;
11+ import { isTTY } from './tty' ;
1112
1213export class Spinner {
1314 private readonly spinner : ora . Ora ;
1415
1516 /** When false, only fail messages will be displayed. */
1617 enabled = true ;
18+ readonly #isTTY = isTTY ( ) ;
1719
1820 constructor ( text ?: string ) {
1921 this . spinner = ora ( {
@@ -22,13 +24,18 @@ export class Spinner {
2224 // when the underlying process is sync.
2325 hideCursor : false ,
2426 discardStdin : false ,
27+ isEnabled : this . #isTTY,
2528 } ) ;
2629 }
2730
2831 set text ( text : string ) {
2932 this . spinner . text = text ;
3033 }
3134
35+ get isSpinning ( ) : boolean {
36+ return this . spinner . isSpinning || ! this . #isTTY;
37+ }
38+
3239 succeed ( text ?: string ) : void {
3340 if ( this . enabled ) {
3441 this . spinner . succeed ( text ) ;
Original file line number Diff line number Diff line change @@ -72,33 +72,28 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
7272 const spinner = new Spinner ( ) ;
7373 spinner . start ( `Generating ${ platform } application bundles (phase: setup)...` ) ;
7474
75- let previousPercentage : number | undefined ;
7675 extraPlugins . push (
7776 new ProgressPlugin ( {
7877 handler : ( percentage : number , message : string ) => {
79- if ( previousPercentage === 1 && percentage !== 0 ) {
80- // In some scenarios in Webpack 5 percentage goes from 1 back to 0.99.
81- // Ex: 0.99 -> 1 -> 0.99 -> 1
82- // This causes the "complete" message to be displayed multiple times.
83-
84- return ;
85- }
78+ const phase = message ? ` (phase: ${ message } )` : '' ;
79+ spinner . text = `Generating ${ platform } application bundles${ phase } ...` ;
8680
8781 switch ( percentage ) {
8882 case 1 :
89- spinner . succeed (
90- `${ platform . replace ( / ^ \w / , ( s ) =>
91- s . toUpperCase ( ) ,
92- ) } application bundle generation complete.`,
93- ) ;
83+ if ( spinner . isSpinning ) {
84+ spinner . succeed (
85+ `${ platform . replace ( / ^ \w / , ( s ) =>
86+ s . toUpperCase ( ) ,
87+ ) } application bundle generation complete.`,
88+ ) ;
89+ }
9490 break ;
9591 case 0 :
96- default :
97- spinner . text = `Generating ${ platform } application bundles (phase: ${ message } )...` ;
92+ if ( ! spinner . isSpinning ) {
93+ spinner . start ( ) ;
94+ }
9895 break ;
9996 }
100-
101- previousPercentage = percentage ;
10297 } ,
10398 } ) ,
10499 ) ;
You can’t perform that action at this time.
0 commit comments