MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / writeRegularFileSync

Function writeRegularFileSync

src/file-limits.ts:96–105  ·  view source on GitHub ↗
(file: string, text: string)

Source from the content-addressed store, hash-verified

94 * to be a regular file.
95 */
96export function writeRegularFileSync(file: string, text: string): void {
97 const fd = fs.openSync(file, fs.constants.O_WRONLY | fs.constants.O_CREAT | (fs.constants.O_NONBLOCK ?? 0), 0o666);
98 try {
99 if (!fs.fstatSync(fd).isFile()) throw notRegularFile(file);
100 fs.ftruncateSync(fd, 0);
101 fs.writeFileSync(fd, text, 'utf-8');
102 } finally {
103 fs.closeSync(fd);
104 }
105}
106
107/**
108 * The longest run of name characters a pattern is given as written. No name,

Callers 4

ensureGitignoreFunction · 0.90
makeGitignoreLocalOnlyFunction · 0.90

Calls 2

notRegularFileFunction · 0.85
openSyncMethod · 0.45

Tested by

no test coverage detected