viewFile

tcmts.cli.views.viewFile · #myh6qg67 · term · runs on the server

uses node:path

The file a definition's view is in: by its (first) name, else by hash.

import type { CodebaseCore } from "#codebase/tcmts/cli/codebase";
import { srcDir } from "#codebase/tcmts/cli/views";
import path_1 from "node:path";

export function viewFile(cb: CodebaseCore, hash: string): string {
  const p = cb.store.pathsOf(hash)[0];
  const jsx = (p ? cb.lookup(p) : [hash]).some((h) => cb.store.getDef(h)?.jsx);
  return path_1.join(
    srcDir(cb),
    `${p ? p.replaceAll(".", "/") : `@${hash}`}${jsx ? ".tsx" : ".ts"}`,
  );
}

uses

used by