Home / Function/ getDiffContent() — astro Function Reference

getDiffContent() — astro Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  6bba8e7c_bf8b_374e_8b24_b01c2bdb5bd4["getDiffContent()"]
  9151bb3d_ee1e_da42_752a_45a9db1dd918["index.ts"]
  6bba8e7c_bf8b_374e_8b24_b01c2bdb5bd4 -->|defined in| 9151bb3d_ee1e_da42_752a_45a9db1dd918
  e251add5_ea46_2280_c246_1b5a023acc3b["add()"]
  e251add5_ea46_2280_c246_1b5a023acc3b -->|calls| 6bba8e7c_bf8b_374e_8b24_b01c2bdb5bd4
  b580bf78_66fd_0e74_f9b4_b1847fcf475e["updateAstroConfig()"]
  b580bf78_66fd_0e74_f9b4_b1847fcf475e -->|calls| 6bba8e7c_bf8b_374e_8b24_b01c2bdb5bd4
  f3e6969a_3f04_43b5_609b_fdfd7fa60748["updatePackageJsonScripts()"]
  f3e6969a_3f04_43b5_609b_fdfd7fa60748 -->|calls| 6bba8e7c_bf8b_374e_8b24_b01c2bdb5bd4
  31c483d1_c4ed_7d00_d4c0_9cbf5313e1d8["updateTSConfig()"]
  31c483d1_c4ed_7d00_d4c0_9cbf5313e1d8 -->|calls| 6bba8e7c_bf8b_374e_8b24_b01c2bdb5bd4
  style 6bba8e7c_bf8b_374e_8b24_b01c2bdb5bd4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/cli/add/index.ts lines 1163–1187

function getDiffContent(input: string, output: string): string | null {
	let changes = [];
	for (const change of diffWords(input, output)) {
		let lines = change.value.trim().split('\n').slice(0, change.count);
		if (lines.length === 0) continue;
		if (change.added) {
			if (!change.value.trim()) continue;
			changes.push(change.value);
		}
	}
	if (changes.length === 0) {
		return null;
	}

	let diffed = output;
	for (let newContent of changes) {
		const coloredOutput = newContent
			.split('\n')
			.map((ln) => (ln ? green(ln) : ''))
			.join('\n');
		diffed = diffed.replace(newContent, coloredOutput);
	}

	return diffed;
}

Domain

Subdomains

Frequently Asked Questions

What does getDiffContent() do?
getDiffContent() is a function in the astro codebase, defined in packages/astro/src/cli/add/index.ts.
Where is getDiffContent() defined?
getDiffContent() is defined in packages/astro/src/cli/add/index.ts at line 1163.
What calls getDiffContent()?
getDiffContent() is called by 4 function(s): add, updateAstroConfig, updatePackageJsonScripts, updateTSConfig.

Analyze Your Own Codebase

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

Try Supermodel Free