testFileBindings

tcmts.cli.main.testFileBindings · #ya3gbihl · term

import { fileBindings } from "#codebase/tcmts/cli/main";

export const testFileBindings = () => {
  const text =
    `import { find as f } from "#codebase/lib";\nimport { join } from "node:path";\nimport os from "node:os";\n` +
    `export const a = 1;\n// tcm: path other.b\nexport const b_1 = 2;\n`;
  const got = [...fileBindings("x.ts", text, "lib")].map(([k, v]) => `${k}=${v}`).join(" ");
  const want =
    "f=path:lib.find join=ext:node:path#join os=ext:node:os#default a=path:lib.a b_1=path:other.b";
  if (got !== want) throw new Error(got);
}

uses