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

Function resolveMainPath

lib/internal/modules/run_main.js:29–45  ·  view source on GitHub ↗

* Get the absolute path to the main entry point. * @param {string} main - Entry point path * @returns {string|undefined}

(main)

Source from the content-addressed store, hash-verified

27 * @returns {string|undefined}
28 */
29function resolveMainPath(main) {
30 /** @type {string} */
31 let mainPath;
32 // Extension searching for the main entry point is supported for backward compatibility.
33 // Module._findPath is monkey-patchable here.
34 const { Module } = require('internal/modules/cjs/loader');
35 mainPath = Module._findPath(path.resolve(main), null, true);
36 if (!mainPath) { return; }
37
38 const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main');
39 if (!preserveSymlinksMain) {
40 const { toRealPath } = require('internal/modules/helpers');
41 mainPath = toRealPath(mainPath);
42 }
43
44 return mainPath;
45}
46
47/**
48 * Determine whether the main entry point should be loaded through the ESM Loader.

Callers 1

executeUserEntryPointFunction · 0.85

Calls 4

getOptionValueFunction · 0.85
toRealPathFunction · 0.85
requireFunction · 0.70
resolveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…