MCPcopy
hub / github.com/freshframework/fresh / updateFile

Function updateFile

packages/plugin-vite/tests/test_utils.ts:12–25  ·  view source on GitHub ↗
(
  filePath: string,
  fn: (text: string) => string | Promise<string>,
)

Source from the content-addressed store, hash-verified

10export const FIXTURE_DIR = path.join(import.meta.dirname!, "fixtures");
11
12export async function updateFile(
13 filePath: string,
14 fn: (text: string) => string | Promise<string>,
15) {
16 const original = await Deno.readTextFile(filePath);
17 const result = await fn(original);
18 await Deno.writeTextFile(filePath, result);
19
20 return {
21 async [Symbol.asyncDispose]() {
22 await Deno.writeTextFile(filePath, original);
23 },
24 };
25}
26
27async function copyDir(from: string, to: string) {
28 const entries = walk(from, {

Callers 1

dev_server_test.tsFile · 0.90

Calls 2

fnFunction · 0.85
readTextFileMethod · 0.80

Tested by

no test coverage detected