@@ -43,7 +43,7 @@ export function format(
43
43
44
44
return results
45
45
. filter ( r => Array . isArray ( r . warnings ) || Array . isArray ( r . errors ) )
46
- . map ( result => [ fi ( result ) , fr ( result ) , '' ] . join ( '\n' ) )
46
+ . map ( result => [ fi ( result ) , ... fr ( result ) ] . join ( '\n' ) )
47
47
. join ( '\n' ) ;
48
48
}
49
49
@@ -52,7 +52,7 @@ function formatInput(
52
52
options : FormatOptions = { }
53
53
) : string {
54
54
const { color : enabled = true } = options ;
55
- const { errors = [ ] , input = '' } = result ;
55
+ const { errors = [ ] , warnings = [ ] , input = '' } = result ;
56
56
57
57
if ( ! input ) {
58
58
return '' ;
@@ -63,8 +63,11 @@ function formatInput(
63
63
const commitText = errors . length > 0 ? input : input . split ( '\n' ) [ 0 ] ;
64
64
65
65
const decoratedInput = enabled ? chalk . bold ( commitText ) : commitText ;
66
+ const hasProblems = errors . length > 0 || warnings . length > 0 ;
66
67
67
- return `${ decoration } input: ${ decoratedInput } ` ;
68
+ return options . verbose || hasProblems
69
+ ? `${ decoration } input: ${ decoratedInput } `
70
+ : '' ;
68
71
}
69
72
70
73
export function formatResult (
@@ -94,18 +97,13 @@ export function formatResult(
94
97
const deco = enabled ? ( chalk [ color ] as any ) ( sign ) : sign ;
95
98
const el = errors . length ;
96
99
const wl = warnings . length ;
97
- const needsHelp = errors . length > 0 || warnings . length > 0 ;
100
+ const hasProblems = errors . length > 0 || warnings . length > 0 ;
98
101
99
- const lines = [
100
- `${ deco } found ${ el } problems, ${ wl } warnings` ,
101
- options . helpUrl && needsHelp ? `Get help: ${ options . helpUrl } ` : undefined
102
- ] ;
102
+ const summary = ( options . verbose || hasProblems ) ? `${ deco } found ${ el } problems, ${ wl } warnings` : undefined ;
103
+ const fmtSummary = enabled && typeof summary === 'string' ? chalk . bold ( summary ) : summary ;
104
+ const help = hasProblems ? `ⓘ Get help: ${ options . helpUrl } ` : undefined ;
103
105
104
- const summary = lines
105
- . filter ( line => typeof line === 'string' )
106
- . join ( '\n' ) ;
107
-
108
- return [ ...problems , enabled ? chalk . bold ( summary ) : summary ] ;
106
+ return [ ...problems , '' , fmtSummary , help ] . filter ( ( line ) : line is string => typeof line === 'string' ) ;
109
107
}
110
108
111
109
export default format ;
0 commit comments