Home / Function/ editFile() — vite Function Reference

editFile() — vite Function Reference

Architecture documentation for the editFile() function in test-utils.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  85ee6e62_f425_ddc2_25fc_6705858559c7["editFile()"]
  c68b21f4_9cd3_3abe_8169_0de2c9650f53["test-utils.ts"]
  85ee6e62_f425_ddc2_25fc_6705858559c7 -->|defined in| c68b21f4_9cd3_3abe_8169_0de2c9650f53
  style 85ee6e62_f425_ddc2_25fc_6705858559c7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

playground/test-utils.ts lines 158–172

export function editFile(
  filename: string,
  encodingOrReplacer: BufferEncoding | null | ((content: string) => string),
  maybeReplacer?: ((content: Buffer) => Buffer) | ((content: string) => string),
): void {
  filename = path.resolve(testDir, filename)
  const [encoding, replacer] = maybeReplacer
    ? [encodingOrReplacer as BufferEncoding | null, maybeReplacer]
    : ['utf-8' as const, encodingOrReplacer as (content: string) => string]
  const content: string | Buffer = fs.readFileSync(filename, encoding)
  const modified = (replacer as (content: string | Buffer) => string | Buffer)(
    content,
  )
  fs.writeFileSync(filename, modified)
}

Domain

Subdomains

Frequently Asked Questions

What does editFile() do?
editFile() is a function in the vite codebase, defined in playground/test-utils.ts.
Where is editFile() defined?
editFile() is defined in playground/test-utils.ts at line 158.

Analyze Your Own Codebase

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

Try Supermodel Free