Skip to content

Commit 7b502b0

Browse files
agentmd: run CLI via tsx in subprocess tests
The release workflow runs `npm test` before `npm run build`, so the new cli.test.ts's dependency on `dist/cli.js` broke the v0.2.0 publish. Invoke the CLI straight from source with `node --import tsx src/cli.ts` instead — matches how the test runner itself loads TypeScript and removes the ordering dependency. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent e73c41a commit 7b502b0

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

packages/agentmd/tests/cli.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { mkdtempSync, writeFileSync } from "node:fs";
55
import { tmpdir } from "node:os";
66
import { join, resolve } from "node:path";
77

8-
const CLI = resolve(import.meta.dirname, "..", "dist", "cli.js");
8+
// Run the CLI from source via tsx so the tests don't depend on a prior
9+
// `npm run build`. The release workflow runs `npm test` before building.
10+
const CLI_SRC = resolve(import.meta.dirname, "..", "src", "cli.ts");
911

1012
function mktmp(): string {
1113
return mkdtempSync(join(tmpdir(), "agentmd-cli-test-"));
@@ -20,10 +22,11 @@ function writeAgent(path: string, opts: { dupHeading?: boolean; missingProcedure
2022
}
2123

2224
function runCli(args: string[], stdin?: string) {
23-
return spawnSync(process.execPath, [CLI, ...args], {
24-
input: stdin,
25-
encoding: "utf8",
26-
});
25+
return spawnSync(
26+
process.execPath,
27+
["--import", "tsx", CLI_SRC, ...args],
28+
{ input: stdin, encoding: "utf8" },
29+
);
2730
}
2831

2932
test("lint: accepts multiple files and aggregates results", () => {

0 commit comments

Comments
 (0)