MCPcopy Create free account
hub / github.com/pulsar-edit/pulsar / resolveModulePath

Function resolveModulePath

src/module-cache.js:237–268  ·  view source on GitHub ↗
(relativePath, parentModule)

Source from the content-addressed store, hash-verified

235}
236
237function resolveModulePath(relativePath, parentModule) {
238 if (!relativePath) return;
239 if (!(parentModule && parentModule.filename)) return;
240
241 if (!nativeModules) nativeModules = process.binding('natives');
242 if (nativeModules.hasOwnProperty(relativePath)) return;
243 if (relativePath[0] === '.') return;
244 if (isAbsolute(relativePath)) return;
245
246 const folderPath = path.dirname(parentModule.filename);
247
248 const range =
249 cache.folders[folderPath] && cache.folders[folderPath][relativePath];
250 if (!range) {
251 const builtinPath = cache.builtins[relativePath];
252 if (builtinPath) {
253 return builtinPath;
254 } else {
255 return;
256 }
257 }
258
259 const candidates = cache.dependencies[relativePath];
260 if (candidates == null) return;
261
262 for (let version in candidates) {
263 const resolvedPath = candidates[version];
264 if (Module._cache[resolvedPath] || isCorePath(resolvedPath)) {
265 if (satisfies(version, range)) return resolvedPath;
266 }
267 }
268}
269
270function registerBuiltins(devMode) {
271 if (

Callers 1

module-cache.jsFile · 0.85

Calls 2

isCorePathFunction · 0.85
satisfiesFunction · 0.85

Tested by

no test coverage detected