@@ -102,8 +102,10 @@ export class SafeArborist extends Arborist {
102102 // @ts -ignore: TS gets grumpy about rest parameters.
103103 ...args . slice ( 1 )
104104 )
105+ // Lazily access constants.ENV[SOCKET_CLI_ACCEPT_RISKS].
106+ const acceptAllRisks = constants . ENV [ SOCKET_CLI_ACCEPT_RISKS ]
105107 // Lazily access constants.ENV[SOCKET_CLI_VIEW_ALL_RISKS].
106- const acceptAllRisks = constants . ENV [ SOCKET_CLI_VIEW_ALL_RISKS ]
108+ const viewAllRisks = constants . ENV [ SOCKET_CLI_VIEW_ALL_RISKS ]
107109 const progress = ipc [ SOCKET_CLI_SAFE_PROGRESS ]
108110 const spinner =
109111 options [ 'silent' ] || ! progress
@@ -115,9 +117,7 @@ export class SafeArborist extends Arborist {
115117 const alertsMap = await getAlertsMapFromArborist ( this , {
116118 spinner,
117119 include :
118- options . dryRun ||
119- options [ 'yes' ] ||
120- acceptAllRisks
120+ acceptAllRisks || options . dryRun || options [ 'yes' ]
121121 ? {
122122 actions : [ 'error' ] ,
123123 blocked : true ,
@@ -134,18 +134,26 @@ export class SafeArborist extends Arborist {
134134 if ( alertsMap . size ) {
135135 process . exitCode = 1
136136 logAlertsMap ( alertsMap , {
137- hideAt : acceptAllRisks ? 'none' : 'middle' ,
137+ hideAt : viewAllRisks ? 'none' : 'middle' ,
138138 output : process . stderr
139139 } )
140140 throw new Error (
141141 stripIndents `
142- Socket ${ binName } exiting due to risks.
143- View all risks - Rerun with environment variable ${ SOCKET_CLI_VIEW_ALL_RISKS } =1.
144- Accept risks - Rerun with environment variable ${ SOCKET_CLI_ACCEPT_RISKS } =1.
142+ Socket ${ binName } exiting due to risks.${
143+ viewAllRisks
144+ ? ''
145+ : `\nView all risks - Rerun with environment variable ${ SOCKET_CLI_VIEW_ALL_RISKS } =1.`
146+ } ${
147+ acceptAllRisks
148+ ? ''
149+ : `\nAccept risks - Rerun with environment variable ${ SOCKET_CLI_ACCEPT_RISKS } =1.`
150+ }
145151 `
146152 )
147153 } else if ( ! options [ 'silent' ] ) {
148- logger . success ( `Socket ${ binName } ${ acceptAllRisks ? 'accepted all' : 'found no' } risks` )
154+ logger . success (
155+ `Socket ${ binName } ${ acceptAllRisks ? 'accepted all' : 'found no' } risks`
156+ )
149157 if ( binName === NPX ) {
150158 logger . log ( `Running ${ options . add ! [ 0 ] } ` )
151159 }
0 commit comments