MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / writeFileSync_DEPRECATED

Function writeFileSync_DEPRECATED

src/utils/slowOperations.ts:251–289  ·  view source on GitHub ↗
(
  filePath: string,
  data: string | NodeJS.ArrayBufferView,
  options?: WriteFileOptionsWithFlush,
)

Source from the content-addressed store, hash-verified

249 * Sync file writes block the event loop and cause performance issues.
250 */
251export function writeFileSync_DEPRECATED(
252 filePath: string,
253 data: string | NodeJS.ArrayBufferView,
254 options?: WriteFileOptionsWithFlush,
255): void {
256 using _ = slowLogging`fs.writeFileSync(${filePath}, ${data})`
257
258 // Check if flush is requested (for object-style options)
259 const needsFlush =
260 options !== null &&
261 typeof options === 'object' &&
262 'flush' in options &&
263 options.flush === true
264
265 if (needsFlush) {
266 // Manual flush: open file, write, fsync, close
267 const encoding =
268 typeof options === 'object' && 'encoding' in options
269 ? options.encoding
270 : undefined
271 const mode =
272 typeof options === 'object' && 'mode' in options
273 ? options.mode
274 : undefined
275 let fd: number | undefined
276 try {
277 fd = openSync(filePath, 'w', mode)
278 fsWriteFileSync(fd, data, { encoding: encoding ?? undefined })
279 fsyncSync(fd)
280 } finally {
281 if (fd !== undefined) {
282 closeSync(fd)
283 }
284 }
285 } else {
286 // No flush needed, use standard writeFileSync
287 fsWriteFileSync(filePath, data, options as WriteFileOptions)
288 }
289}

Callers 14

loadSettingsFromFlagFunction · 0.85
showInvalidConfigDialogFunction · 0.85
handleFilenameSubmitFunction · 0.85
editPromptInEditorFunction · 0.85
profileReportFunction · 0.85
writeLockFileFunction · 0.85
updateFunction · 0.85
saveInstalledPluginsV2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected