MCPcopy Index your code
hub / github.com/Noumena-Network/code / appendAsync

Function appendAsync

src/utils/debug.ts:271–304  ·  view source on GitHub ↗
(
  needMkdir: boolean,
  dir: string,
  path: string,
  content: string,
)

Source from the content-addressed store, hash-verified

269// Module-level so .bind captures only its explicit args, not the
270// writeFn closure's parent scope (Jarred, #22257).
271async function appendAsync(
272 needMkdir: boolean,
273 dir: string,
274 path: string,
275 content: string,
276): Promise<void> {
277 if (debugLoggingUnavailable) {
278 return
279 }
280 if (needMkdir) {
281 try {
282 await mkdir(dir, { recursive: true })
283 } catch (error) {
284 if (isFsInaccessible(error)) {
285 markDebugLoggingUnavailable(error)
286 return
287 }
288 }
289 }
290 try {
291 const budgetedContent = await applyDebugLogBudgetAsync(path, content)
292 if (budgetedContent === null) {
293 return
294 }
295 await appendFile(path, budgetedContent)
296 void updateLatestDebugLogSymlink()
297 } catch (error) {
298 if (isFsInaccessible(error)) {
299 markDebugLoggingUnavailable(error)
300 return
301 }
302 throw error
303 }
304}
305
306function noop(): void {}
307

Callers

nothing calls this directly

Calls 4

mkdirFunction · 0.85
isFsInaccessibleFunction · 0.85
applyDebugLogBudgetAsyncFunction · 0.85

Tested by

no test coverage detected