MCPcopy Index your code
hub / github.com/nodejs/node / trySelfParentPath

Function trySelfParentPath

lib/internal/modules/cjs/loader.js:642–654  ·  view source on GitHub ↗

* Tries to get the absolute file path of the parent module. * @param {Module} parent The parent module object. * @returns {string|false|void}

(parent)

Source from the content-addressed store, hash-verified

640 * @returns {string|false|void}
641 */
642function trySelfParentPath(parent) {
643 if (!parent) { return false; }
644
645 if (parent.filename) {
646 return parent.filename;
647 } else if (parent.id === '<repl>' || parent.id === 'internal/preload') {
648 try {
649 return process.cwd() + path.sep;
650 } catch {
651 return false;
652 }
653 }
654}
655
656/**
657 * Attempt to resolve a module request using the parent module package metadata.

Callers 2

tryPackageMapResolveCJSFunction · 0.85
loader.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…