testPackRefusesAmbiguousExports
Pack refuses what it can't export unambiguously.
import { tcmBin } from "#codebase/tcmts/cli/test/e2e/harness"; import { setUp } from "#codebase/tcmts/cli/test/e2e/pack"; import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; export const testPackRefusesAmbiguousExports = () => { const { dir, spawn, tcm, write } = setUp(); write("other.ts", `// tcm: namespace other\nexport const greet = 1;\n`); tcm("add", "other.ts"); const clash = spawn(process.execPath, [tcmBin(), "pack", "greet", "other", "--name", "x"]); assert.notEqual(clash.status, 0); assert.match(clash.out, /two values would be exported as greet: greet\.greet and other\.greet; pack them under separate subpaths/); assert.match(spawn(process.execPath, [tcmBin(), "pack", "nope", "--name", "x"]).out, /'nope' isn't a definition or namespace/); assert.match(spawn(process.execPath, [tcmBin(), "pack", "--bin", "x", "--name", "x"]).out, /--bin wants cmd=<name>, not 'x'/); // the output directory is replaced, so it has to be an earlier pack assert.match(spawn(process.execPath, [tcmBin(), "pack", "greet", "--name", "x", "--out", "."]).out, /--out \.: .* isn't empty or an earlier tcm pack/); assert.ok(fs.existsSync(path.join(dir, ".tcm", "codebase.sqlite"))); }