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

Function getLocalBinSearch

packages/cli-exec/src/lookup.ts:419–457  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

417 * phase and kept as diagnostics for not-found errors.
418 */
419export async function getLocalBinSearch(cwd: string): Promise<LocalBinSearch> {
420 const searchRoot = await getCanonicalPath(path.resolve(cwd));
421 const ancestorSearch = await getAncestorDirectorySearch(searchRoot);
422 const skippedNodeModules: SkippedNodeModules[] = [];
423 const directories: string[] = [];
424
425 for (const directory of ancestorSearch.directories) {
426 const nodeModulesDirectory = path.join(directory, 'node_modules');
427 const parentDirectories =
428 ancestorSearch.stopReason === 'project-root-marker'
429 ? getDirectoriesBetween(ancestorSearch.stoppedAt, directory)
430 : getDirectoriesBetween(directory, searchRoot);
431 const skippedReason = await getSkippedNodeModulesReason(
432 nodeModulesDirectory,
433 parentDirectories
434 );
435
436 if (skippedReason) {
437 skippedNodeModules.push({
438 directory: nodeModulesDirectory,
439 reason: skippedReason,
440 });
441 continue;
442 }
443
444 directories.push(path.join(nodeModulesDirectory, '.bin'));
445 }
446
447 return {
448 directories,
449 diagnostics: {
450 searchRoot,
451 stoppedAt: ancestorSearch.stoppedAt,
452 stopReason: ancestorSearch.stopReason,
453 markerPath: ancestorSearch.markerPath,
454 skippedNodeModules,
455 },
456 };
457}
458
459/**
460 * Walks ancestor directories until a project marker or filesystem root is hit.

Callers 2

prependLocalBinsToPathFunction · 0.90
resolveCliInvocationFunction · 0.85

Calls 7

getCanonicalPathFunction · 0.90
getDirectoriesBetweenFunction · 0.90
pushMethod · 0.65
resolveMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected