@@ -14,7 +14,7 @@ const collectValues = extension => extension.split(',')
1414
1515const commander = require ( 'commander' )
1616 . name ( 'jsonlint' )
17- . usage ( '[options] [<pattern> ...]' )
17+ . usage ( '[options] [<file, directory, pattern> ...]' )
1818 . description ( description )
1919 . option ( '-s, --sort-keys' , 'sort object keys (not when prettifying)' )
2020 . option ( '-E, --extensions [ext]' , 'file extensions to process for directory walk' , collectValues , [ 'json' , 'JSON' ] )
@@ -30,6 +30,7 @@ const commander = require('commander')
3030 . option ( '-e, --environment [env]' , 'which specification of JSON Schema the validation file uses' )
3131 . option ( '-l, --log-files' , 'print only the parsed file names to stdout' )
3232 . option ( '-q, --quiet' , 'do not print the parsed json to stdout' )
33+ . option ( '-n, --continue' , 'continue with other files if an error occurs' )
3334 . option ( '-p, --pretty-print' , 'prettify the input instead of stringifying the parsed object' )
3435 . option ( '-P, --pretty-print-invalid' , 'force pretty-printing even for invalid input' )
3536 . option ( '-r, --trailing-newline' , 'ensure a line break at the end of the output' )
@@ -57,6 +58,9 @@ const options = commander.opts()
5758const extensions = options . extensions . map ( extension => '.' + extension )
5859
5960function logNormalError ( error , file ) {
61+ if ( process . exitCode > 0 ) {
62+ console . log ( )
63+ }
6064 console . log ( 'File:' , file )
6165 console . error ( error . message )
6266}
@@ -135,7 +139,11 @@ function processContents (source, file) {
135139 logNormalError ( e , file )
136140 }
137141 }
138- process . exit ( 1 )
142+ if ( options . continue ) {
143+ process . exitCode = 1
144+ } else {
145+ process . exit ( 1 )
146+ }
139147 }
140148}
141149
0 commit comments