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

Function tryFile

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

* Check if the file exists and is not a directory if using `--preserve-symlinks` and `isMain` is false or * `--preserve-symlinks-main` and `isMain` is true , keep symlinks intact, otherwise resolve to the absolute realpath. * @param {string} requestPath The path to the file to load. * @param {boo

(requestPath, isMain)

Source from the content-addressed store, hash-verified

589 * @returns {string|undefined}
590 */
591function tryFile(requestPath, isMain) {
592 const rc = _stat(requestPath);
593 if (rc !== 0) { return; }
594 if (getOptionValue(isMain ? '--preserve-symlinks-main' : '--preserve-symlinks')) {
595 return path.resolve(requestPath);
596 }
597 return toRealPath(requestPath);
598}
599
600/**
601 * Given a path, check if the file exists with any of the set extensions.

Callers 3

tryPackageFunction · 0.70
tryExtensionsFunction · 0.70
finalizeEsmResolutionFunction · 0.70

Calls 4

_statFunction · 0.85
getOptionValueFunction · 0.85
toRealPathFunction · 0.85
resolveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…