testFileNamedWithADashIsImported
A file whose name isn't an identifier (getting-started) is imported by its name in quotes, and edited back so.
import { okIn, tempDir } from "#codebase/tcmts/cli/test/e2e/harness"; import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; export const testFileNamedWithADashIsImported = () => { const dir = tempDir("files dash"); const ok = (...args: string[]) => okIn(dir, ...args); ok("init"); fs.mkdirSync(path.join(dir, "pages")); fs.writeFileSync(path.join(dir, "pages", "getting-started.md"), "# Getting started\n\nHello.\n"); ok("add", "pages/getting-started.md", "--into", "docs"); fs.writeFileSync(path.join(dir, "scratch.ts"), `// tcm: namespace site\nimport { "getting-started" as gettingStarted } from "#codebase/docs";\n\nexport const intro = (): string => gettingStarted.split("\\n")[0]!;\n`); ok("add"); assert.match(ok("run", "site.intro"), /^# Getting started$/m); assert.match(ok("view", "site.intro"), /import \{ "getting-started" as \w+ \} from "#codebase\/docs";/); ok("edit", "site.intro", "--force"); assert.match(ok("check"), /= identical +site\.intro/); }