followMove

tcmts.cli.files.followMove · #3p7c7yys · term · runs on the server

uses Buffer

After the file from moved to to: the pages whose links change, as new definitions, by name.

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import { fileDefinition, filesIn, relinked } from "#codebase/tcmts/cli/files";
import type { DefRecord } from "#codebase/tcmts/core/types";

export function followMove(cb: Codebase, from: string, to: string): Map<string, DefRecord> {
  const out = new Map<string, DefRecord>();
  for (const [page, rec] of filesIn(cb, "")) {
    const text = relinked(cb, page, rec, from, to);
    if (text !== undefined) out.set(page, fileDefinition(cb, page, "md", Buffer.from(text, "utf8")).def);
  }
  return out;
}

uses

used by