7
7
*/
8
8
// tslint:disable
9
9
// TODO: cleanup this file, it's copied as is from Angular CLI.
10
- import { logging , tags , terminal } from '@angular-devkit/core' ;
10
+ import { logging , tags } from '@angular-devkit/core' ;
11
11
import { WebpackLoggingCallback } from '@angular-devkit/build-webpack' ;
12
12
import * as path from 'path' ;
13
-
14
-
15
- const { bold, green, red, reset, white, yellow } = terminal ;
13
+ import { colors as ansiColors } from '../../utils/color' ;
16
14
17
15
export function formatSize ( size : number ) : string {
18
16
if ( size <= 0 ) {
@@ -37,8 +35,8 @@ export function generateBundleStats(
37
35
} ,
38
36
colors : boolean ,
39
37
) : string {
40
- const g = ( x : string ) => ( colors ? bold ( green ( x ) ) : x ) ;
41
- const y = ( x : string ) => ( colors ? bold ( yellow ( x ) ) : x ) ;
38
+ const g = ( x : string ) => ( colors ? ansiColors . bold . green ( x ) : x ) ;
39
+ const y = ( x : string ) => ( colors ? ansiColors . bold . yellow ( x ) : x ) ;
42
40
43
41
const id = info . id ? y ( info . id . toString ( ) ) : '' ;
44
42
const size = typeof info . size === 'number' ? ` ${ formatSize ( info . size ) } ` : '' ;
@@ -53,14 +51,14 @@ export function generateBundleStats(
53
51
}
54
52
55
53
export function generateBuildStats ( hash : string , time : number , colors : boolean ) : string {
56
- const w = ( x : string ) => colors ? bold ( white ( x ) ) : x ;
54
+ const w = ( x : string ) => colors ? ansiColors . bold . white ( x ) : x ;
57
55
return `Date: ${ w ( new Date ( ) . toISOString ( ) ) } - Hash: ${ w ( hash ) } - Time: ${ w ( '' + time ) } ms`
58
56
}
59
57
60
58
export function statsToString ( json : any , statsConfig : any ) {
61
59
const colors = statsConfig . colors ;
62
- const rs = ( x : string ) => colors ? reset ( x ) : x ;
63
- const w = ( x : string ) => colors ? bold ( white ( x ) ) : x ;
60
+ const rs = ( x : string ) => colors ? ansiColors . reset ( x ) : x ;
61
+ const w = ( x : string ) => colors ? ansiColors . bold . white ( x ) : x ;
64
62
65
63
const changedChunksStats = json . chunks
66
64
. filter ( ( chunk : any ) => chunk . rendered )
@@ -97,8 +95,8 @@ const ERRONEOUS_WARNINGS_FILTER = (warning: string) => ![
97
95
98
96
export function statsWarningsToString ( json : any , statsConfig : any ) : string {
99
97
const colors = statsConfig . colors ;
100
- const rs = ( x : string ) => colors ? reset ( x ) : x ;
101
- const y = ( x : string ) => colors ? bold ( yellow ( x ) ) : x ;
98
+ const rs = ( x : string ) => colors ? ansiColors . reset ( x ) : x ;
99
+ const y = ( x : string ) => colors ? ansiColors . bold . yellow ( x ) : x ;
102
100
const warnings = [ ...json . warnings ] ;
103
101
if ( json . children ) {
104
102
warnings . push ( ...json . children
@@ -116,8 +114,8 @@ export function statsWarningsToString(json: any, statsConfig: any): string {
116
114
117
115
export function statsErrorsToString ( json : any , statsConfig : any ) : string {
118
116
const colors = statsConfig . colors ;
119
- const rs = ( x : string ) => colors ? reset ( x ) : x ;
120
- const r = ( x : string ) => colors ? bold ( red ( x ) ) : x ;
117
+ const rs = ( x : string ) => colors ? ansiColors . reset ( x ) : x ;
118
+ const r = ( x : string ) => colors ? ansiColors . bold . red ( x ) : x ;
121
119
const errors = [ ...json . errors ] ;
122
120
if ( json . children ) {
123
121
errors . push ( ...json . children
0 commit comments