fix(test): reject diff ref flag values

This commit is contained in:
Vincent Koc
2026-06-21 19:59:55 +02:00
parent 8086cffd17
commit 7069d95720
4 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ const MAX_TERM_LENGTH = 80;
function readRefOptionValue(argv, index, optionName) {
const value = argv[index + 1];
if (value === undefined || value === "" || value.startsWith("--")) {
if (value === undefined || value === "" || value.startsWith("-")) {
throw new Error(`${optionName} requires a value`);
}
return value;
+1 -1
View File
@@ -62,7 +62,7 @@ function resolveCommit({ ref, cwd, maxBuffer }) {
function readRefValue(argv, index, optionName) {
const value = argv[index + 1];
if (value === undefined || value === "" || value.startsWith("--")) {
if (value === undefined || value === "" || value.startsWith("-")) {
throw new Error(`${optionName} requires a value`);
}
return value;
@@ -11,7 +11,11 @@ describe("check-docs-i18n-glossary", () => {
it("rejects missing diff ref values", () => {
expect(() => parseArgs(["--base", "--head", "HEAD"])).toThrow("--base requires a value");
expect(() => parseArgs(["--base", "-h", "--head", "HEAD"])).toThrow(
"--base requires a value",
);
expect(() => parseArgs(["--head"])).toThrow("--head requires a value");
expect(() => parseArgs(["--head", "-h"])).toThrow("--head requires a value");
expect(() => parseArgs(["--base", ""])).toThrow("--base requires a value");
});
});
@@ -12,7 +12,11 @@ describe("merge-head-diff-base", () => {
it("rejects missing refs", () => {
expect(() => parseArgs(["--base", "--head", "HEAD"])).toThrow("--base requires a value");
expect(() => parseArgs(["--base", "-h", "--head", "HEAD"])).toThrow(
"--base requires a value",
);
expect(() => parseArgs(["--head"])).toThrow("--head requires a value");
expect(() => parseArgs(["--head", "-h"])).toThrow("--head requires a value");
expect(() => parseArgs(["--base", ""])).toThrow("--base requires a value");
});