Home / Function/ check() — astro Function Reference

check() — astro Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  af0b1988_4d61_cf3e_7915_f0b3cfb3401b["check()"]
  d06f1dae_d2ec_dd68_b710_e9bdefa6984f["index.ts"]
  af0b1988_4d61_cf3e_7915_f0b3cfb3401b -->|defined in| d06f1dae_d2ec_dd68_b710_e9bdefa6984f
  style af0b1988_4d61_cf3e_7915_f0b3cfb3401b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/cli/check/index.ts lines 6–44

export async function check(flags: Flags) {
	ensureProcessNodeEnv('production');
	const logger = createLoggerFromFlags(flags);
	const getPackageOpts = {
		skipAsk: !!flags.yes || !!flags.y,
		cwd: flags.root,
	};
	// @ts-ignore For some unknown reason, in CI TS isn't able to get the type here even though it works locally.
	const checkPackage = await getPackage<typeof import('@astrojs/check')>(
		'@astrojs/check',
		logger,
		getPackageOpts,
		['typescript'],
	);
	const typescript = await getPackage('typescript', logger, getPackageOpts);

	if (!checkPackage || !typescript) {
		logger.error(
			'check',
			'The `@astrojs/check` and `typescript` packages are required for this command to work. Please manually install them into your project and try again.',
		);
		return;
	}

	if (!flags.noSync && !flags.help) {
		// Run sync before check to make sure types are generated.
		// NOTE: In the future, `@astrojs/check` can expose a `before lint` hook so that this works during `astro check --watch` too.
		// For now, we run this once as usually `astro check --watch` is ran alongside `astro dev` which also calls `astro sync`.
		const { default: sync } = await import('../../core/sync/index.js');
		await sync(flagsToAstroInlineConfig(flags));
	}

	const { check: checker, parseArgsAsCheckConfig } = checkPackage;

	const config = parseArgsAsCheckConfig(process.argv);

	logger.info('check', `Getting diagnostics for Astro files in ${path.resolve(config.root)}...`);
	return await checker(config);
}

Domain

Subdomains

Frequently Asked Questions

What does check() do?
check() is a function in the astro codebase, defined in packages/astro/src/cli/check/index.ts.
Where is check() defined?
check() is defined in packages/astro/src/cli/check/index.ts at line 6.

Analyze Your Own Codebase

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

Try Supermodel Free