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

Function getDirectoriesBetween

packages/cli-exec/src/fsutils.ts:28–47  ·  view source on GitHub ↗
(parent: string, child: string)

Source from the content-addressed store, hash-verified

26 * Returns the inclusive directory chain from `parent` to `child`.
27 */
28export function getDirectoriesBetween(parent: string, child: string): string[] {
29 const directories = [];
30 let current = path.resolve(child);
31 const resolvedParent = path.resolve(parent);
32
33 while (true) {
34 directories.push(current);
35
36 if (current === resolvedParent) {
37 return directories.reverse();
38 }
39
40 const next = path.dirname(current);
41 if (next === current) {
42 return [];
43 }
44
45 current = next;
46 }
47}
48
49/**
50 * Reads stat metadata while distinguishing absent paths from inspection errors.

Callers 3

getLocalBinSearchFunction · 0.90

Calls 3

reverseMethod · 0.80
pushMethod · 0.65
resolveMethod · 0.45

Tested by

no test coverage detected