MCPcopy Create free account
hub / github.com/Snapchat/Valdi / resolvePath

Function resolvePath

src/valdi_modules/src/valdi/valdi_core/src/ModuleLoader.ts:72–86  ·  view source on GitHub ↗
(path: string, fromResolvedPath: ResolvedPath)

Source from the content-addressed store, hash-verified

70 absolutePath: absolutePath,
71 };
72}
73
74function resolveAbsoluteImportFromPath(path: string): ResolvedPath {
75 return resolveAbsoluteImport(normalizePath(path.split('/')));
76}
77
78function resolvePath(path: string, fromResolvedPath: ResolvedPath): ResolvedPath {
79 const importPathEntries = path.split('/');
80 if (importPathEntries[0] === '.' || importPathEntries[0] === '..') {
81 // Relative import
82
83 const combinedPath = fromResolvedPath.directoryPaths.slice();
84 combinedPath.push(...importPathEntries);
85 const normalized = normalizePath(combinedPath);
86 return resolveAbsoluteImport(normalized);
87 } else {
88 // Absolute import
89 const normalized = normalizePath(importPathEntries);

Callers 1

makeRequireMethod · 0.85

Calls 4

normalizePathFunction · 0.85
resolveAbsoluteImportFunction · 0.85
splitMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected