INNER CODE UNIT · TypeScript

readOptionalFileTextForDelta

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

async function readOptionalFileTextForDelta(path: string, delta: AppliedPatchDelta): Promise<string | null> {
  await noteExistingPathDeltaSupport(path, delta);
  try {
    return await readFileText(path);
  } catch (error) {
    if (errorCode(error) === 'ENOENT') return null;
    delta.exact = false;
    return null;
  }
}

async function noteExistingPathDeltaSupport(path: string, delta: AppliedPatchDelta): Promise<void> {
  try {
    const metadata = await getMetadata(path);
    if (!(metadata.isFile && !metadata.isSymlink)) delta.exact = false;
  } catch (error) {
    if (errorCode(error) !== 'ENOENT') delta.exact = false;
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…