analyze

tcmts.core.test.hash.analyze · #q7olitkf · term · runs on the server

uses node:path

import { analyzeFile } from "#codebase/tcmts/core/analyze";
import type { Analysis } from "#codebase/tcmts/core/analyze";
import { dir, n } from "#codebase/tcmts/core/test/hash";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";

export function analyze(source: string): Analysis {
  const file = path.join(dir, `f${n++}.ts`);
  fs.writeFileSync(file, source);
  const a = analyzeFile(file, {
    cacheDir: path.join(dir, ".tcm", "cache"),
    resolveName: (name) => {
      throw new Error(`unknown ${name}`);
    },
  });
  assert.deepEqual(
    a.diagnostics.map((d) => d.message),
    [],
  );
  assert.deepEqual(a.errors, []);
  return a;
}

uses

used by