MCPcopy Create free account
hub / github.com/dyoshikawa/rulesync / readOrInitializeFileContent

Function readOrInitializeFileContent

src/utils/file.ts:29–40  ·  view source on GitHub ↗
(
  filePath: string,
  initialContent: string = "",
)

Source from the content-addressed store, hash-verified

27}
28
29export async function readOrInitializeFileContent(
30 filePath: string,
31 initialContent: string = "",
32): Promise<string> {
33 if (await fileExists(filePath)) {
34 return await readFileContent(filePath);
35 } else {
36 await ensureDir(dirname(filePath));
37 await writeFileContent(filePath, initialContent);
38 return initialContent;
39 }
40}
41
42/**
43 * Converts OS-native path separators to POSIX forward slashes.

Callers 15

file.test.tsFile · 0.85
fromRulesyncMcpMethod · 0.85
fromRulesyncMcpMethod · 0.85
fromRulesyncMcpMethod · 0.85
fromRulesyncMcpMethod · 0.85

Calls 4

fileExistsFunction · 0.85
readFileContentFunction · 0.85
ensureDirFunction · 0.85
writeFileContentFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…