File tree 2 files changed +19
-17
lines changed
packages/angular_devkit/build_angular/src
2 files changed +19
-17
lines changed Original file line number Diff line number Diff line change 8
8
9
9
import * as ora from 'ora' ;
10
10
import { colors } from './color' ;
11
+ import { isTTY } from './tty' ;
11
12
12
13
export class Spinner {
13
14
private readonly spinner : ora . Ora ;
14
15
15
16
/** When false, only fail messages will be displayed. */
16
17
enabled = true ;
18
+ readonly #isTTY = isTTY ( ) ;
17
19
18
20
constructor ( text ?: string ) {
19
21
this . spinner = ora ( {
@@ -22,13 +24,18 @@ export class Spinner {
22
24
// when the underlying process is sync.
23
25
hideCursor : false ,
24
26
discardStdin : false ,
27
+ isEnabled : this . #isTTY,
25
28
} ) ;
26
29
}
27
30
28
31
set text ( text : string ) {
29
32
this . spinner . text = text ;
30
33
}
31
34
35
+ get isSpinning ( ) : boolean {
36
+ return this . spinner . isSpinning || ! this . #isTTY;
37
+ }
38
+
32
39
succeed ( text ?: string ) : void {
33
40
if ( this . enabled ) {
34
41
this . spinner . succeed ( text ) ;
Original file line number Diff line number Diff line change @@ -72,33 +72,28 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
72
72
const spinner = new Spinner ( ) ;
73
73
spinner . start ( `Generating ${ platform } application bundles (phase: setup)...` ) ;
74
74
75
- let previousPercentage : number | undefined ;
76
75
extraPlugins . push (
77
76
new ProgressPlugin ( {
78
77
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 } ...` ;
86
80
87
81
switch ( percentage ) {
88
82
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
+ }
94
90
break ;
95
91
case 0 :
96
- default :
97
- spinner . text = `Generating ${ platform } application bundles (phase: ${ message } )...` ;
92
+ if ( ! spinner . isSpinning ) {
93
+ spinner . start ( ) ;
94
+ }
98
95
break ;
99
96
}
100
-
101
- previousPercentage = percentage ;
102
97
} ,
103
98
} ) ,
104
99
) ;
You can’t perform that action at this time.
0 commit comments