* PATH probing treats absent candidates as normal. Permission failures are only * useful when they explain why a local project bin was rejected.
( candidate: string, localBinSearch: LocalBinSearch, diagnostics: ResolutionDiagnostics )
| 285 | * useful when they explain why a local project bin was rejected. |
| 286 | */ |
| 287 | async function canAccessCommandCandidate( |
| 288 | candidate: string, |
| 289 | localBinSearch: LocalBinSearch, |
| 290 | diagnostics: ResolutionDiagnostics |
| 291 | ): Promise<boolean> { |
| 292 | try { |
| 293 | await access( |
| 294 | candidate, |
| 295 | process.platform === 'win32' |
| 296 | ? constants.F_OK |
| 297 | : constants.F_OK | constants.X_OK |
| 298 | ); |
| 299 | return true; |
| 300 | } catch (error) { |
| 301 | if (!isMissingPathError(error)) { |
| 302 | await recordInaccessibleLocalBinCandidate( |
| 303 | candidate, |
| 304 | error, |
| 305 | localBinSearch, |
| 306 | diagnostics |
| 307 | ); |
| 308 | } |
| 309 | |
| 310 | return false; |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * Preserve local-bin access failures as diagnostics. Global PATH entries keep |
no test coverage detected