@@ -58,29 +58,33 @@ class Doctor extends BaseCommand {
5858 ...( isWindows
5959 ? [ ]
6060 : [
61- [ 'Perms check on cached files' , 'checkFilesPermission' , [ this . npm . cache , true , R_OK ] ] ,
6261 [
62+ 'Perms check on cached files' ,
63+ 'checkFilesPermission' ,
64+ [ this . npm . cache , true , R_OK ]
65+ ] , [
6366 'Perms check on local node_modules' ,
6467 'checkFilesPermission' ,
65- [ this . npm . localDir , true ] ,
66- ] ,
67- [
68+ [ this . npm . localDir , true , R_OK | W_OK , true ] ,
69+ ] , [
6870 'Perms check on global node_modules' ,
6971 'checkFilesPermission' ,
70- [ this . npm . globalDir , false ] ,
71- ] ,
72- [
72+ [ this . npm . globalDir , false , R_OK ] ,
73+ ] , [
7374 'Perms check on local bin folder' ,
7475 'checkFilesPermission' ,
75- [ this . npm . localBin , false , R_OK | W_OK | X_OK ] ,
76- ] ,
77- [
76+ [ this . npm . localBin , false , R_OK | W_OK | X_OK , true ] ,
77+ ] , [
7878 'Perms check on global bin folder' ,
7979 'checkFilesPermission' ,
8080 [ this . npm . globalBin , false , X_OK ] ,
8181 ] ,
8282 ] ) ,
83- [ 'Verify cache contents' , 'verifyCachedFiles' , [ this . npm . flatOptions . cache ] ] ,
83+ [
84+ 'Verify cache contents' ,
85+ 'verifyCachedFiles' ,
86+ [ this . npm . flatOptions . cache ]
87+ ] ,
8488 // TODO:
8589 // - ensure arborist.loadActual() runs without errors and no invalid edges
8690 // - ensure package-lock.json matches loadActual()
@@ -202,10 +206,7 @@ class Doctor extends BaseCommand {
202206 }
203207 }
204208
205- async checkFilesPermission ( root , shouldOwn , mask = null ) {
206- if ( mask === null ) {
207- mask = shouldOwn ? R_OK | W_OK : R_OK
208- }
209+ async checkFilesPermission ( root , shouldOwn , mask , missingOk ) {
209210
210211 let ok = true
211212
@@ -218,8 +219,10 @@ class Doctor extends BaseCommand {
218219 for ( const f of files ) {
219220 tracker . silly ( 'checkFilesPermission' , f . substr ( root . length + 1 ) )
220221 const st = await lstat ( f ) . catch ( er => {
221- ok = false
222- tracker . warn ( 'checkFilesPermission' , 'error getting info for ' + f )
222+ if ( ! missingOk || err . code === 'ENOENT' ) {
223+ ok = false
224+ tracker . warn ( 'checkFilesPermission' , 'error getting info for ' + f )
225+ }
223226 } )
224227
225228 tracker . completeWork ( 1 )
0 commit comments