MCPcopy Create free account
hub / github.com/nodejs/node / resolvePackageNameToPackageJson

Function resolvePackageNameToPackageJson

test/fixtures/snapshot/typescript.js:42694–42713  ·  view source on GitHub ↗

* @internal * Does not try `@types/${packageName}` - use a second pass if needed.

(packageName, containingDirectory, options, host, cache)

Source from the content-addressed store, hash-verified

42692 * Does not try `@types/${packageName}` - use a second pass if needed.
42693 */
42694 function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) {
42695 var moduleResolutionState = {
42696 compilerOptions: options,
42697 host: host,
42698 traceEnabled: isTraceEnabled(options, host),
42699 failedLookupLocations: [],
42700 packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
42701 conditions: ts.emptyArray,
42702 features: NodeResolutionFeatures.None,
42703 requestContainingDirectory: containingDirectory,
42704 reportDiagnostic: ts.noop
42705 };
42706 return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
42707 if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
42708 var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules");
42709 var candidate = ts.combinePaths(nodeModulesFolder, packageName);
42710 return getPackageJsonInfo(candidate, /*onlyRecordFailures*/ false, moduleResolutionState);
42711 }
42712 });
42713 }
42714 ts.resolvePackageNameToPackageJson = resolvePackageNameToPackageJson;
42715 /**
42716 * Given a set of options, returns the set of type directive names

Callers

nothing calls this directly

Calls 2

isTraceEnabledFunction · 0.85
getPackageJsonInfoFunction · 0.85

Tested by

no test coverage detected