@@ -10,7 +10,6 @@ const semver = require('semver')
1010const { promisify } = require ( 'util' )
1111const log = require ( '../utils/log-shim.js' )
1212const ansiTrim = require ( '../utils/ansi-trim.js' )
13- const isWindows = require ( '../utils/is-windows.js' )
1413const ping = require ( '../utils/ping.js' )
1514const {
1615 registry : { default : defaultRegistry } ,
@@ -55,32 +54,36 @@ class Doctor extends BaseCommand {
5554 [ 'node -v' , 'getLatestNodejsVersion' , [ ] ] ,
5655 [ 'npm config get registry' , 'checkNpmRegistry' , [ ] ] ,
5756 [ 'which git' , 'getGitPath' , [ ] ] ,
58- ...( isWindows
57+ ...( process . platform === 'win32'
5958 ? [ ]
6059 : [
61- [ 'Perms check on cached files' , 'checkFilesPermission' , [ this . npm . cache , true , R_OK ] ] ,
6260 [
61+ 'Perms check on cached files' ,
62+ 'checkFilesPermission' ,
63+ [ this . npm . cache , true , R_OK ] ,
64+ ] , [
6365 'Perms check on local node_modules' ,
6466 'checkFilesPermission' ,
65- [ this . npm . localDir , true ] ,
66- ] ,
67- [
67+ [ this . npm . localDir , true , R_OK | W_OK , true ] ,
68+ ] , [
6869 'Perms check on global node_modules' ,
6970 'checkFilesPermission' ,
70- [ this . npm . globalDir , false ] ,
71- ] ,
72- [
71+ [ this . npm . globalDir , false , R_OK ] ,
72+ ] , [
7373 'Perms check on local bin folder' ,
7474 'checkFilesPermission' ,
75- [ this . npm . localBin , false , R_OK | W_OK | X_OK ] ,
76- ] ,
77- [
75+ [ this . npm . localBin , false , R_OK | W_OK | X_OK , true ] ,
76+ ] , [
7877 'Perms check on global bin folder' ,
7978 'checkFilesPermission' ,
8079 [ this . npm . globalBin , false , X_OK ] ,
8180 ] ,
8281 ] ) ,
83- [ 'Verify cache contents' , 'verifyCachedFiles' , [ this . npm . flatOptions . cache ] ] ,
82+ [
83+ 'Verify cache contents' ,
84+ 'verifyCachedFiles' ,
85+ [ this . npm . flatOptions . cache ] ,
86+ ] ,
8487 // TODO:
8588 // - ensure arborist.loadActual() runs without errors and no invalid edges
8689 // - ensure package-lock.json matches loadActual()
@@ -202,11 +205,7 @@ class Doctor extends BaseCommand {
202205 }
203206 }
204207
205- async checkFilesPermission ( root , shouldOwn , mask = null ) {
206- if ( mask === null ) {
207- mask = shouldOwn ? R_OK | W_OK : R_OK
208- }
209-
208+ async checkFilesPermission ( root , shouldOwn , mask , missingOk ) {
210209 let ok = true
211210
212211 const tracker = log . newItem ( root , 1 )
@@ -218,8 +217,11 @@ class Doctor extends BaseCommand {
218217 for ( const f of files ) {
219218 tracker . silly ( 'checkFilesPermission' , f . substr ( root . length + 1 ) )
220219 const st = await lstat ( f ) . catch ( er => {
221- ok = false
222- tracker . warn ( 'checkFilesPermission' , 'error getting info for ' + f )
220+ // if it can't be missing, or if it can and the error wasn't that it was missing
221+ if ( ! missingOk || er . code !== 'ENOENT' ) {
222+ ok = false
223+ tracker . warn ( 'checkFilesPermission' , 'error getting info for ' + f )
224+ }
223225 } )
224226
225227 tracker . completeWork ( 1 )
0 commit comments