44const debug = require ( 'debug' ) ( 'lockfile-lint' )
55const main = require ( '../src/main' )
66
7+ const isSupported =
8+ process . platform !== 'win32' || process . env . CI || process . env . TERM === 'xterm-256color'
9+
10+ const symbolsDefault = {
11+ info : 'ℹ' ,
12+ success : '✔' ,
13+ error : '✖'
14+ }
15+
16+ const symbolsFallback = {
17+ info : 'i' ,
18+ success : '√' ,
19+ error : '×'
20+ }
21+
22+ const symbols = isSupported ? symbolsDefault : symbolsFallback
23+
24+ const RESET = '\x1b[0m'
25+ const RED = '\x1b[31m'
26+ const GREEN = '\x1b[32m'
27+ const YELLOW = '\x1b[33m'
28+
729let config
830
931try {
@@ -57,10 +79,15 @@ try {
5779 validators
5880 } )
5981} catch ( error ) {
60- console . error ( 'ABORTING lockfile lint process due to error exceptions' , '\n' )
82+ console . error (
83+ YELLOW ,
84+ `${ symbols . info } ABORTING lockfile lint process due to error exceptions` ,
85+ '\n' ,
86+ RESET
87+ )
6188 console . error ( error . message , '\n' )
6289 console . error ( error . stack , '\n' )
63- console . error ( ' error: command failed with exit code 1' , '\n' )
90+ console . error ( RED , ` ${ symbols . error } Error : command failed with exit code 1` , '\n' , RESET )
6491 process . exit ( 1 )
6592}
6693
@@ -71,10 +98,8 @@ debug(`total validator failures: ${validatorFailures}`)
7198debug ( `total validator successes: ${ validatorSuccesses } ` )
7299
73100if ( validatorFailures !== 0 ) {
74- console . error ( ' error: command failed with exit code 1' , '\n' )
101+ console . error ( RED , ` ${ symbols . error } Error: security issues detected!` , '\n' , RESET )
75102 process . exit ( 1 )
76103} else {
77- const GREEN = '\x1b[32m'
78- const RESET = '\x1b[0m'
79- console . info ( GREEN , 'No issues detected' , '\n' , RESET )
104+ console . info ( GREEN , `${ symbols . success } No issues detected` , '\n' , RESET )
80105}
0 commit comments