MCPcopy Create free account
hub / github.com/angular/angular / resolve

Function resolve

vscode-ng-language-service/common/resolver.ts:20–42  ·  view source on GitHub ↗
(
  packageName: string,
  location: string,
  rootPackage?: string,
)

Source from the content-addressed store, hash-verified

18}
19
20export function resolve(
21 packageName: string,
22 location: string,
23 rootPackage?: string,
24): NodeModule | undefined {
25 rootPackage = rootPackage || packageName;
26 try {
27 const packageJsonPath = require.resolve(`${rootPackage}/package.json`, {
28 paths: [location],
29 });
30 // Do not use require() to read JSON files since it's a potential security
31 // vulnerability.
32 const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
33 const resolvedPath = require.resolve(packageName, {
34 paths: [location],
35 });
36 return {
37 name: packageName,
38 resolvedPath,
39 version: new Version(packageJson.version),
40 };
41 } catch {}
42}
43
44export class Version {
45 readonly major: number;

Callers 9

resolveWithMinVersionFunction · 0.90
test_constants.tsFile · 0.50
onSuggestStrictModeFunction · 0.50
getDiagnosticsForFileFunction · 0.50
spawnFunction · 0.50

Calls 2

resolveMethod · 0.65
parseMethod · 0.65

Tested by

no test coverage detected