fix(scripts): validate iOS node CLI values before help

This commit is contained in:
Vincent Koc
2026-06-21 23:00:22 +02:00
parent 2ef61eb782
commit 6b45e9af7a
2 changed files with 14 additions and 2 deletions
+6 -2
View File
@@ -40,6 +40,10 @@ const hasFlag = (flag: string) => argv.includes(flag);
const BOOLEAN_FLAGS = new Set(["--dangerous", "--help", "-h", "--json"]);
const VALUE_FLAGS = new Set(["--node", "--token", "--url", "--wait-seconds"]);
function isMissingOptionValue(value: string | undefined): boolean {
return !value || BOOLEAN_FLAGS.has(value) || VALUE_FLAGS.has(value) || value.startsWith("--");
}
function failCli(message: string): never {
writeStderrLine(message);
process.exit(1);
@@ -53,7 +57,7 @@ function validateArgs(): void {
}
if (VALUE_FLAGS.has(arg)) {
const value = argv[index + 1];
if (!value || value.startsWith("--")) {
if (isMissingOptionValue(value)) {
failCli(`${arg} requires a value`);
}
index += 1;
@@ -63,11 +67,11 @@ function validateArgs(): void {
}
}
validateArgs();
if (hasFlag("--help") || hasFlag("-h")) {
writeStdoutLine(usage());
process.exit(0);
}
validateArgs();
type NodeListPayload = {
ts?: number;