Home / Function/ getPackageInfo() — astro Function Reference

getPackageInfo() — astro Function Reference

Architecture documentation for the getPackageInfo() function in importPackage.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  495034c4_630b_8d19_14b5_3d1a1a8fdcd7["getPackageInfo()"]
  e0c225c9_e989_934d_19e8_8e80b7a6857f["importPackage.ts"]
  495034c4_630b_8d19_14b5_3d1a1a8fdcd7 -->|defined in| e0c225c9_e989_934d_19e8_8e80b7a6857f
  03b2c8e8_4089_3932_b6ef_8b977e709ddd["importEditorIntegration()"]
  03b2c8e8_4089_3932_b6ef_8b977e709ddd -->|calls| 495034c4_630b_8d19_14b5_3d1a1a8fdcd7
  50c308bd_8d34_b5e9_d78b_b7c836400f7e["importPrettier()"]
  50c308bd_8d34_b5e9_d78b_b7c836400f7e -->|calls| 495034c4_630b_8d19_14b5_3d1a1a8fdcd7
  439a1b66_5cf5_548a_a61c_a6e91bfb6e5c["getPrettierPluginPath()"]
  439a1b66_5cf5_548a_a61c_a6e91bfb6e5c -->|calls| 495034c4_630b_8d19_14b5_3d1a1a8fdcd7
  04e7aa8c_49d9_5d70_5c55_1e8ed9a4a9d1["parsePackageVersion()"]
  495034c4_630b_8d19_14b5_3d1a1a8fdcd7 -->|calls| 04e7aa8c_49d9_5d70_5c55_1e8ed9a4a9d1
  style 495034c4_630b_8d19_14b5_3d1a1a8fdcd7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/language-tools/language-server/src/importPackage.ts lines 35–51

export function getPackageInfo(packageName: string, fromPath: string[]): PackageInfo | undefined {
	const paths = [];
	if (isTrusted) {
		paths.unshift(...fromPath);
	}

	try {
		const packageJSON = require.resolve(packageName + '/package.json', { paths });
		return {
			directory: dirname(packageJSON),
			entrypoint: require.resolve(packageName, { paths }),
			version: parsePackageVersion(require(packageJSON).version),
		};
	} catch {
		return undefined;
	}
}

Domain

Subdomains

Frequently Asked Questions

What does getPackageInfo() do?
getPackageInfo() is a function in the astro codebase, defined in packages/language-tools/language-server/src/importPackage.ts.
Where is getPackageInfo() defined?
getPackageInfo() is defined in packages/language-tools/language-server/src/importPackage.ts at line 35.
What does getPackageInfo() call?
getPackageInfo() calls 1 function(s): parsePackageVersion.
What calls getPackageInfo()?
getPackageInfo() is called by 3 function(s): getPrettierPluginPath, importEditorIntegration, importPrettier.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free