@@ -15,7 +15,8 @@ const help = require('./help');
15
15
* Behavioural rules
16
16
*/
17
17
const rules = {
18
- fromStdin : ( input , flags ) => input . length === 0 &&
18
+ fromStdin : ( input , flags ) =>
19
+ input . length === 0 &&
19
20
typeof flags . from !== 'string' &&
20
21
typeof flags . to !== 'string' &&
21
22
! flags . edit
@@ -54,10 +55,15 @@ const configuration = {
54
55
}
55
56
} ;
56
57
57
- const cli = meow ( {
58
- help : `[input] reads from stdin if --edit, --from and --to are omitted\n${ help ( configuration ) } ` ,
59
- description : `${ pkg . name } @${ pkg . version } - ${ pkg . description } `
60
- } , configuration ) ;
58
+ const cli = meow (
59
+ {
60
+ help : `[input] reads from stdin if --edit, --from and --to are omitted\n${ help (
61
+ configuration
62
+ ) } `,
63
+ description : `${ pkg . name } @${ pkg . version } - ${ pkg . description } `
64
+ } ,
65
+ configuration
66
+ ) ;
61
67
62
68
const load = seed => core . load ( seed ) ;
63
69
@@ -70,28 +76,31 @@ function main(options) {
70
76
const input = fromStdin ? stdin ( ) : core . read ( range ) ;
71
77
const fmt = new chalk . constructor ( { enabled : flags . color } ) ;
72
78
73
- return input
74
- . then ( raw => Array . isArray ( raw ) ? raw : [ raw ] )
75
- . then ( messages => Promise . all ( messages . map ( commit => {
76
- return load ( getSeed ( flags ) )
77
- . then ( opts => core . lint ( commit , opts . rules ) )
78
- . then ( report => {
79
- const formatted = core . format ( report , { color : flags . color } ) ;
79
+ return input . then ( raw => ( Array . isArray ( raw ) ? raw : [ raw ] ) ) . then ( messages =>
80
+ Promise . all (
81
+ messages . map ( commit => {
82
+ return load ( getSeed ( flags ) )
83
+ . then ( opts => core . lint ( commit , opts . rules ) )
84
+ . then ( report => {
85
+ const formatted = core . format ( report , { color : flags . color } ) ;
80
86
81
- if ( ! flags . quiet ) {
82
- console . log ( `${ fmt . grey ( '⧗' ) } input: ${ fmt . bold ( commit . split ( '\n' ) [ 0 ] ) } ` ) ;
83
- console . log ( formatted . join ( '\n' ) ) ;
84
- }
87
+ if ( ! flags . quiet ) {
88
+ console . log (
89
+ `${ fmt . grey ( '⧗' ) } input: ${ fmt . bold ( commit . split ( '\n' ) [ 0 ] ) } `
90
+ ) ;
91
+ console . log ( formatted . join ( '\n' ) ) ;
92
+ }
85
93
86
- if ( report . errors . length > 0 ) {
87
- const error = new Error ( formatted [ formatted . length - 1 ] ) ;
88
- error . type = pkg . name ;
89
- throw error ;
90
- }
91
- return console . log ( '' ) ;
92
- } ) ;
93
- } )
94
- ) ) ;
94
+ if ( report . errors . length > 0 ) {
95
+ const error = new Error ( formatted [ formatted . length - 1 ] ) ;
96
+ error . type = pkg . name ;
97
+ throw error ;
98
+ }
99
+ return console . log ( '' ) ;
100
+ } ) ;
101
+ } )
102
+ )
103
+ ) ;
95
104
}
96
105
97
106
function getSeed ( seed ) {
@@ -101,15 +110,14 @@ function getSeed(seed) {
101
110
}
102
111
103
112
// Start the engine
104
- main ( cli )
105
- . catch ( err =>
106
- setTimeout ( ( ) => {
107
- if ( err . type === pkg . name ) {
108
- process . exit ( 1 ) ;
109
- }
110
- throw err ;
111
- } )
112
- ) ;
113
+ main ( cli ) . catch ( err =>
114
+ setTimeout ( ( ) => {
115
+ if ( err . type === pkg . name ) {
116
+ process . exit ( 1 ) ;
117
+ }
118
+ throw err ;
119
+ } )
120
+ ) ;
113
121
114
122
// Catch unhandled rejections globally
115
123
process . on ( 'unhandledRejection' , ( reason , promise ) => {
0 commit comments