Home / Function/ checkExamples() — astro Function Reference

checkExamples() — astro Function Reference

Architecture documentation for the checkExamples() function in check.js from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  cba20645_62bd_70c0_caff_f96cee1c8243["checkExamples()"]
  6e63560f_8c71_c453_90bf_78fa760e9716["check.js"]
  cba20645_62bd_70c0_caff_f96cee1c8243 -->|defined in| 6e63560f_8c71_c453_90bf_78fa760e9716
  640900ab_d36d_8a46_5d24_e4d6f85b27e6["prepareExample()"]
  cba20645_62bd_70c0_caff_f96cee1c8243 -->|calls| 640900ab_d36d_8a46_5d24_e4d6f85b27e6
  34c517d7_e696_dc4f_c74f_44acfd958e7a["resetExample()"]
  cba20645_62bd_70c0_caff_f96cee1c8243 -->|calls| 34c517d7_e696_dc4f_c74f_44acfd958e7a
  style cba20645_62bd_70c0_caff_f96cee1c8243 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/smoke/check.js lines 11–66

function checkExamples() {
	let examples = readdirSync('./examples', { withFileTypes: true });
	examples = examples.filter((dirent) => dirent.isDirectory()).filter((dirent) => !skippedExamples.includes(dirent.name));

	console.log(`Running astro check on ${examples.length} examples...`);

	// Run astro check in parallel with 5 at most
	const checkPromises = [];
	const limit = pLimit(5);

	for (const example of examples) {
		checkPromises.push(
			limit(
				() =>
					new Promise((resolve) => {
						// Sometimes some examples may get deleted, but after a `git pull` the directory still exists.
						// This can stall the process time as it'll typecheck the entire monorepo, so do a quick exist
						// check here before typechecking this directory.
						if (!existsSync(path.join('./examples/', example.name, 'package.json'))) {
							resolve(0);
							return;
						}

						const originalConfig = prepareExample(example.name);
						let data = '';
						const child = spawn('node', ['../../packages/astro/bin/astro.mjs', 'check'], {
							cwd: path.join('./examples', example.name),
							env: { ...process.env, FORCE_COLOR: 'true' },
						});

						child.stdout.on('data', function (buffer) {
							data += buffer.toString();
						});

						child.on('exit', (code) => {
							if (code !== 0) {
								console.error(data);
							}
							if (originalConfig) {
								resetExample(example.name, originalConfig);
							}
							resolve(code);
						});
					})
			)
		);
	}

	Promise.all(checkPromises).then((codes) => {
		if (codes.some((code) => code !== 0)) {
			process.exit(1);
		}

		console.log('No errors found!');
	});
}

Domain

Subdomains

Frequently Asked Questions

What does checkExamples() do?
checkExamples() is a function in the astro codebase, defined in scripts/smoke/check.js.
Where is checkExamples() defined?
checkExamples() is defined in scripts/smoke/check.js at line 11.
What does checkExamples() call?
checkExamples() calls 2 function(s): prepareExample, resetExample.

Analyze Your Own Codebase

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

Try Supermodel Free