MCPcopy Create free account
hub / github.com/cloudflare/computer / readWorkdirAsText

Function readWorkdirAsText

packages/computer/src/git/diff.ts:306–318  ·  view source on GitHub ↗
(
  readFile: ReadFileFn,
  dir: string,
  filepath: string,
)

Source from the content-addressed store, hash-verified

304}
305
306async function readWorkdirAsText(
307 readFile: ReadFileFn,
308 dir: string,
309 filepath: string,
310): Promise<string> {
311 try {
312 const data = await readFile(`${dir}/${filepath}`);
313 if (typeof data === "string") return data;
314 return new TextDecoder("utf-8", { fatal: false, ignoreBOM: false }).decode(data);
315 } catch {
316 return "";
317 }
318}

Callers 1

collectDiffEntriesFunction · 0.85

Calls 1

readFileFunction · 0.50

Tested by

no test coverage detected