MCPcopy
hub / github.com/tleunen/babel-plugin-module-resolver / resolvePath

Function resolvePath

src/resolvePath.js:99–118  ·  view source on GitHub ↗
(sourcePath, currentFile, opts)

Source from the content-addressed store, hash-verified

97const resolvers = [resolvePathFromAliasConfig, resolvePathFromRootConfig];
98
99export default function resolvePath(sourcePath, currentFile, opts) {
100 // `.` and `./` are specific paths, we can't transfrom them
101 if (isRelativePath(sourcePath) || sourcePath === '.' || sourcePath === './') {
102 return sourcePath;
103 }
104
105 const normalizedOpts = normalizeOptions(currentFile, opts);
106
107 // File param is a relative path from the environment current working directory
108 // (not from cwd param)
109 const absoluteCurrentFile = path.resolve(currentFile);
110 let resolvedPath = null;
111
112 resolvers.some(resolver => {
113 resolvedPath = resolver(sourcePath, absoluteCurrentFile, normalizedOpts);
114 return resolvedPath !== null;
115 });
116
117 return resolvedPath;
118}

Callers 2

index.test.jsFile · 0.90
mapPathStringFunction · 0.70

Calls 1

isRelativePathFunction · 0.90

Tested by

no test coverage detected