fix(scripts): reject short flag docker package values

This commit is contained in:
Vincent Koc 2026-06-21 21:24:30 +02:00
parent ebb670b208
commit 6daf9307e0
No known key found for this signature in database
2 changed files with 4 additions and 2 deletions

View file

@ -67,14 +67,14 @@ function resolveTimeoutMs(envName, defaultValue) {
function readOptionValue(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;
}
function readEqualsOptionValue(value, optionName) {
if (value === "" || value.startsWith("--")) {
if (value === "" || value.startsWith("-")) {
throw new Error(`${optionName} requires a value`);
}
return value;

View file

@ -98,7 +98,9 @@ describe("package-openclaw-for-docker", () => {
for (const flag of ["--output-dir", "--output-name", "--source-dir"]) {
expect(() => parseArgs([flag])).toThrow(`${flag} requires a value`);
expect(() => parseArgs([flag, "--skip-build"])).toThrow(`${flag} requires a value`);
expect(() => parseArgs([flag, "-h"])).toThrow(`${flag} requires a value`);
expect(() => parseArgs([`${flag}=`])).toThrow(`${flag} requires a value`);
expect(() => parseArgs([`${flag}=-h`])).toThrow(`${flag} requires a value`);
}
});