Home / Function/ getPreference() — astro Function Reference

getPreference() — astro Function Reference

Architecture documentation for the getPreference() function in index.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  dbd24844_d9f2_0606_a8f9_7b3c7cdd9389["getPreference()"]
  f7d3fd10_bcd7_7c85_17b8_a4feb9026da8["index.ts"]
  dbd24844_d9f2_0606_a8f9_7b3c7cdd9389 -->|defined in| f7d3fd10_bcd7_7c85_17b8_a4feb9026da8
  4ec23106_e310_07dc_a9e9_e382aeb6a997["preferences()"]
  4ec23106_e310_07dc_a9e9_e382aeb6a997 -->|calls| dbd24844_d9f2_0606_a8f9_7b3c7cdd9389
  a2c2e7e3_9b77_6370_f433_b592e516c189["prettyPrint()"]
  dbd24844_d9f2_0606_a8f9_7b3c7cdd9389 -->|calls| a2c2e7e3_9b77_6370_f433_b592e516c189
  style dbd24844_d9f2_0606_a8f9_7b3c7cdd9389 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/cli/preferences/index.ts lines 128–152

async function getPreference(
	settings: AstroSettings,
	key: PreferenceKey,
	{ location = 'project' }: SubcommandOptions,
) {
	try {
		let value = await settings.preferences.get(key, { location });
		if (value && typeof value === 'object' && !Array.isArray(value)) {
			if (Object.keys(value).length === 0) {
				value = dlv(DEFAULT_PREFERENCES, key);
				console.log(msg.preferenceDefaultIntro(key));
			}
			prettyPrint({ [key]: value });
			return 0;
		}
		if (value === undefined) {
			const defaultValue = await settings.preferences.get(key);
			console.log(msg.preferenceDefault(key, defaultValue));
			return 0;
		}
		console.log(msg.preferenceGet(key, value));
		return 0;
	} catch {}
	return 1;
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does getPreference() do?
getPreference() is a function in the astro codebase, defined in packages/astro/src/cli/preferences/index.ts.
Where is getPreference() defined?
getPreference() is defined in packages/astro/src/cli/preferences/index.ts at line 128.
What does getPreference() call?
getPreference() calls 1 function(s): prettyPrint.
What calls getPreference()?
getPreference() is called by 1 function(s): preferences.

Analyze Your Own Codebase

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

Try Supermodel Free