File tree Expand file tree Collapse file tree 3 files changed +28
-10
lines changed Expand file tree Collapse file tree 3 files changed +28
-10
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ import {
12
12
resolveCWD ,
13
13
watchEllipsis ,
14
14
wpackLogoSmall ,
15
+ printErrorHeading ,
16
+ printSuccessHeading ,
17
+ printWarningHeading ,
15
18
} from './utils' ;
16
19
17
20
/**
@@ -53,28 +56,31 @@ export function build(options: ProgramOptions | undefined): void {
53
56
const builder : Build = new Build ( projectConfig , cwd ) ;
54
57
builder
55
58
. build ( )
56
- . then ( ( { status, log } ) => {
59
+ . then ( ( { status, log, warnings } ) => {
57
60
if ( status === 'success' ) {
58
61
spinner . succeed ( `${ wpackLogoSmall } build successful.` ) ;
59
62
} else {
60
63
spinner . warn ( `${ wpackLogoSmall } built with warnings.` ) ;
61
64
}
62
- console . log ( '' ) ;
63
- console . log (
64
- `${ chalk . bgGreenBright (
65
- chalk . bold . hex ( '#000000' ) ( ' OUTPUT ' )
66
- ) } `
67
- ) ;
68
- console . log ( '' ) ;
65
+ printSuccessHeading ( 'OUTPUT' ) ;
69
66
console . log ( log ) ;
70
67
console . log ( '' ) ;
68
+ if ( status === 'warn' && Array . isArray ( warnings ) ) {
69
+ printWarningHeading ( 'WARNINGS' ) ;
70
+ warnings . forEach ( w => {
71
+ console . log ( w ) ;
72
+ console . log ( '' ) ;
73
+ } ) ;
74
+ }
71
75
endBuildInfo ( ) ;
72
76
console . log ( '' ) ;
73
77
process . exit ( 0 ) ;
74
78
} )
75
79
. catch ( err => {
76
80
spinner . fail ( `${ wpackLogoSmall } build failed.` ) ;
81
+ printErrorHeading ( 'ERROR' ) ;
77
82
console . error ( err ) ;
83
+ console . log ( '' ) ;
78
84
process . exit ( 1 ) ;
79
85
} ) ;
80
86
} catch ( e ) {
Original file line number Diff line number Diff line change @@ -199,6 +199,14 @@ export function printWarningHeading(msg: string = 'WARNING'): void {
199
199
console . log ( '' ) ;
200
200
}
201
201
202
+ export function printSuccessHeading ( msg : string = 'OUTPUT' ) : void {
203
+ console . log ( '' ) ;
204
+ console . log (
205
+ `${ chalk . bgGreenBright ( chalk . bold . hex ( '#000000' ) ( ` ${ msg } ` ) ) } `
206
+ ) ;
207
+ console . log ( '' ) ;
208
+ }
209
+
202
210
export const bulletSymbol = chalk . magenta ( figures . pointer ) ;
203
211
204
212
export const wpackLink = `${ chalk . blue . underline ( 'https://wpack.io' ) } ` ;
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export class Build {
23
23
public build ( ) : Promise < {
24
24
status : 'error' | 'warn' | 'success' ;
25
25
log : string ;
26
+ warnings ?: string [ ] ;
26
27
} > {
27
28
return new Promise ( ( resolve , reject ) => {
28
29
const config = new CreateWebpackConfig (
@@ -47,6 +48,8 @@ export class Build {
47
48
modules : false ,
48
49
builtAt : false ,
49
50
timings : false ,
51
+ warnings : false ,
52
+ errors : false ,
50
53
} ) ;
51
54
52
55
if ( ! messages . errors . length && ! messages . warnings . length ) {
@@ -57,11 +60,12 @@ export class Build {
57
60
} ) ;
58
61
}
59
62
if ( messages . errors . length ) {
60
- reject ( messages . errors . join ( '\n' ) ) ;
63
+ reject ( messages . errors . join ( '\n\n ' ) ) ;
61
64
}
62
65
resolve ( {
63
66
status : 'warn' ,
64
- log : `${ outputLog } \n\n${ messages . warnings . join ( '\n' ) } ` ,
67
+ log : outputLog ,
68
+ warnings : messages . warnings ,
65
69
} ) ;
66
70
} ) ;
67
71
} ) ;
You can’t perform that action at this time.
0 commit comments