Skip to content

Commit e4f6959

Browse files
committed
Fix CLI integration test to use local build directly
Instead of using 'npx ctxc' which may pick up a globally installed version, run the local build directly with 'node dist/bin/index.js'. This makes the test more reliable and reproducible across different environments.
1 parent 47cbde1 commit e4f6959

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

test/cli-agent.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import { spawn } from "child_process";
1616
import { mkdtemp, rm } from "fs/promises";
17+
import { resolve } from "path";
1718
import { tmpdir } from "os";
1819
import { join } from "path";
1920

@@ -26,12 +27,15 @@ interface TestResult {
2627

2728
let testIndexPath: string | null = null;
2829

30+
// Path to the local CLI build
31+
const CLI_PATH = resolve(import.meta.dirname, "../dist/bin/index.js");
32+
2933
async function runCLI(
3034
args: string[],
3135
timeoutMs = 60000
3236
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
3337
return new Promise((resolve) => {
34-
const proc = spawn("npx", ["ctxc", ...args], {
38+
const proc = spawn(process.execPath, [CLI_PATH, ...args], {
3539
cwd: process.cwd(),
3640
env: process.env,
3741
timeout: timeoutMs,

0 commit comments

Comments
 (0)