Home / Function/ fromFile() — astro Function Reference

fromFile() — astro Function Reference

Architecture documentation for the fromFile() function in mutable-data-store.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  984300fd_1eec_d077_7646_e72d4b799e08["fromFile()"]
  ecb98618_124a_e276_dd98_561beaedc6ea["MutableDataStore"]
  984300fd_1eec_d077_7646_e72d4b799e08 -->|defined in| ecb98618_124a_e276_dd98_561beaedc6ea
  b9b63c11_6a4e_7397_8529_58f75e95637b["fromString()"]
  984300fd_1eec_d077_7646_e72d4b799e08 -->|calls| b9b63c11_6a4e_7397_8529_58f75e95637b
  style 984300fd_1eec_d077_7646_e72d4b799e08 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/content/mutable-data-store.ts lines 431–445

	static async fromFile(filePath: string | URL) {
		try {
			if (existsSync(filePath)) {
				const data = await fs.readFile(filePath, 'utf-8');
				const store = await MutableDataStore.fromString(data);
				store.#file = filePath;
				return store;
			} else {
				await fs.mkdir(new URL('./', filePath), { recursive: true });
			}
		} catch {}
		const store = new MutableDataStore();
		store.#file = filePath;
		return store;
	}

Subdomains

Calls

Frequently Asked Questions

What does fromFile() do?
fromFile() is a function in the astro codebase, defined in packages/astro/src/content/mutable-data-store.ts.
Where is fromFile() defined?
fromFile() is defined in packages/astro/src/content/mutable-data-store.ts at line 431.
What does fromFile() call?
fromFile() calls 1 function(s): fromString.

Analyze Your Own Codebase

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

Try Supermodel Free