INNER CODE UNIT · TypeScript

writeFileWithMissingParentRetry

totec448-spec/chat-on-steroids · src/main/codex/apply-patch/index.ts:434

async function writeFileWithMissingParentRetry(path: string, contents: string): Promise<void> {
  try {
    await writeFile(path, contents);
    return;
  } catch (error) {
    if (errorCode(error) !== 'ENOENT') {
      throw new Error(`Failed to write file ${path}`, { cause: error });
    }
  }
  const parent = nodePath.dirname(path);
  await withContext(
    createDirectory(parent, { recursive: true }),
    () => `Failed to create parent directories for ${path}`
  );
  await withContext(writeFile(path, contents), () => `Failed to write file ${path}`);
}

/** `print_summary`: the summary of changes, in git-style format. */

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…