MCPcopy Create free account
hub / github.com/vercel/vercel / canAccessCommandCandidate

Function canAccessCommandCandidate

packages/cli-exec/src/lookup.ts:287–312  ·  view source on GitHub ↗

* 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
)

Source from the content-addressed store, hash-verified

285 * useful when they explain why a local project bin was rejected.
286 */
287async 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

Callers 1

findCommandInPathFunction · 0.85

Calls 2

isMissingPathErrorFunction · 0.90

Tested by

no test coverage detected