fix(scripts): reject short flag values in release docs parsers

This commit is contained in:
Vincent Koc
2026-06-21 21:39:32 +02:00
parent 9adf3d92bd
commit 82f43f0a62
6 changed files with 36 additions and 9 deletions

View File

@@ -83,7 +83,7 @@ function parseArgs(argv) {
function readOptionValue(argv, index, option) {
const value = argv[index + 1] ?? "";
if (!value || value.startsWith("--")) {
if (!value || value.startsWith("-")) {
throw new Error(`Missing value for ${option}.`);
}
return value;

View File

@@ -94,7 +94,7 @@ function parsePositiveIntegerArg(raw, label) {
function readRequiredValue(argv, index, label) {
const value = argv[index + 1];
if (!value || value.startsWith("--")) {
if (!value || value.startsWith("-")) {
throw new Error(`${label} requires a value`);
}
return value;
@@ -116,7 +116,10 @@ export function parseArgs(argv) {
continue;
}
if (part === "--max-errors") {
maxErrors = parsePositiveIntegerArg(argv[index + 1], "--max-errors");
maxErrors = parsePositiveIntegerArg(
readRequiredValue(argv, index, "--max-errors"),
"--max-errors",
);
index += 1;
continue;
}

View File

@@ -59,7 +59,7 @@ function parseArgs(argv) {
function readOptionValue(argv, index, option) {
const value = argv[index + 1] ?? "";
if (!value || value.startsWith("--")) {
if (!value || value.startsWith("-")) {
throw new Error(`Missing value for ${option}.`);
}
return value;