fix(cli): reject empty analyze and artifact target paths (#2687)

Squash merge of https://github.com/morluto/rea/pull/2687.

Co-authored-by: LouisChen <3361008+chqcjq@users.noreply.github.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
This commit is contained in:
LouisChen
2026-10-13 23:48:09 +08:00
committed by GitHub
co-authored by LouisChen morluto
parent 8b1549a264
commit 2b98fc5f51
3 changed files with 40 additions and 2 deletions
@@ -0,0 +1,35 @@
import { expect } from "vitest";
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
import { cliTest } from "../support/cli/cliFixture.js";
cliTest.for(["analyze", "inspect-artifact"])(
"%s rejects an explicitly empty target before resolving it against cwd",
async (command, { cli }) => {
const cwd = await createTestTempDirectory("rea-empty-target-");
const result = await cli.run({
arguments: [command, "", "--json"],
cwd,
});
expect(result.exitCode).toBe(1);
expect(result.json).toMatchObject({ code: "VALIDATION_ERROR" });
expect(result.stdout).toContain("path");
expect(result.stdout).not.toContain("directory_requires_file");
},
);
cliTest(
"inspect-artifact still admits an explicitly selected current directory",
async ({ cli }) => {
const cwd = await createTestTempDirectory("rea-explicit-target-");
const result = await cli.run({
arguments: ["inspect-artifact", ".", "--json"],
cwd,
});
expect(result.exitCode).toBe(1);
expect(result.json).toMatchObject({
code: "target_unavailable",
details: { path: cwd, constraint: "directory_requires_file" },
});
},
);