MCPcopy Create free account
hub / github.com/d1ll0n/stack-packer / findDirectoryInTree

Function findDirectoryInTree

src/project/paths.ts:16–21  ·  view source on GitHub ↗
(_path: string, parentName: string)

Source from the content-addressed store, hash-verified

14export const containsChild = (_path: string, child: string) => fs.existsSync(path.join(_path, child))
15
16export const findDirectoryInTree = (_path: string, parentName: string) => {
17 const parents = getDir(_path).split(path.sep);
18 const indexOfParent = parents.lastIndexOf(parentName);
19 if (indexOfParent < 0) return undefined;
20 return path.join(path.parse(_path).root, ...parents.slice(0, indexOfParent + 1));
21}
22
23export const findChild = (_path: string, childOrPossibleChildren: string | string[]): string | undefined => {
24 if (Array.isArray(childOrPossibleChildren)) {

Callers 2

Calls 1

getDirFunction · 0.85

Tested by

no test coverage detected