hashOf

tcmts.cli.test.e2e.react.hashOf · #fm3sa3qd · term · runs on the server

uses node:sqlite

import path from "node:path";
import { DatabaseSync } from "node:sqlite";

export function hashOf(dir: string, name: string): string {
  const db = new DatabaseSync(path.join(dir, ".tcm", "codebase.sqlite"), { readOnly: true });
  try {
    return (db.prepare("SELECT hash FROM names WHERE path = ?").get(name) as { hash: string }).hash;
  } finally {
    db.close();
  }
}

used by