Home / Function/ run() — astro Function Reference

run() — astro Function Reference

Architecture documentation for the run() function in memory-default.js from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  70bdf6e3_6697_8912_2b51_426e20fcc639["run()"]
  216fe01f_2d97_9501_a24a_5c78f8458c69["memory-default.js"]
  70bdf6e3_6697_8912_2b51_426e20fcc639 -->|defined in| 216fe01f_2d97_9501_a24a_5c78f8458c69
  style 70bdf6e3_6697_8912_2b51_426e20fcc639 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

benchmark/make-project/memory-default.js lines 7–101

export async function run(projectDir) {
	await fs.rm(projectDir, { recursive: true, force: true });
	await fs.mkdir(new URL('./src/pages/blog', projectDir), { recursive: true });
	await fs.mkdir(new URL('./src/content/blog', projectDir), { recursive: true });

	const promises = [];

	for (let i = 0; i < 100; i++) {
		const content = `\
---
const i = ${i};
---

<span>{i}</span>
`;
		promises.push(
			fs.writeFile(new URL(`./src/pages/page-${i}.astro`, projectDir), content, 'utf-8'),
		);
	}

	for (let i = 0; i < 100; i++) {
		const content = `\
# Article ${i}

${loremIpsum}
`;
		promises.push(
			fs.writeFile(new URL(`./src/content/blog/article-${i}.md`, projectDir), content, 'utf-8'),
		);
	}

	for (let i = 0; i < 100; i++) {
		const content = `\
# Post ${i}

${loremIpsum}
`;
		promises.push(
			fs.writeFile(new URL(`./src/content/blog/post-${i}.mdx`, projectDir), content, 'utf-8'),
		);
	}

	await fs.writeFile(
		new URL(`./src/pages/blog/[...slug].astro`, projectDir),
		`\
---
import { getCollection, render } from 'astro:content';
export async function getStaticPaths() {
  const blogEntries = await getCollection('blog');
  return blogEntries.map(entry => ({
    params: { slug: entry.id }, props: { entry },
  }));
}
const { entry } = Astro.props;
const { Content } = await render(entry);
---
<h1>{entry.data.title}</h1>
<Content />
`,
		'utf-8',
	);

	await Promise.all(promises);

	await fs.writeFile(
		new URL(`./src/content.config.ts`, projectDir),
		`\
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';

const blog = defineCollection({
	loader: glob({ pattern: '**/*.{md,mdx}', base: './src/content/blog' }),
	schema: z.object({
		title: z.string(),
	}),
});

export const collections = { blog };
`,
		'utf-8',

Subdomains

Frequently Asked Questions

What does run() do?
run() is a function in the astro codebase, defined in benchmark/make-project/memory-default.js.
Where is run() defined?
run() is defined in benchmark/make-project/memory-default.js at line 7.

Analyze Your Own Codebase

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

Try Supermodel Free