v4.2.0 beta
- fixes for 550 folder issue - updated excludes option format
This commit is contained in:
+6
-16
@@ -90,24 +90,14 @@ export function optionalInt(argumentName: string, rawValue: string): number | un
|
||||
throw new Error(`${argumentName}: invalid parameter - you provided "${rawValue}". Try a whole number (no decimals) instead like 1234`);
|
||||
}
|
||||
|
||||
export function optionalStringArray(argumentName: string, rawValue: string): string[] | undefined {
|
||||
export function optionalStringArray(argumentName: string, rawValue: string[]): string[] | undefined {
|
||||
if (typeof rawValue === "string") {
|
||||
throw new Error(`${argumentName}: invalid parameter - you provided "${rawValue}". This option expects an list in the EXACT format described in the readme`);
|
||||
}
|
||||
|
||||
if (rawValue.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const valueTrim = rawValue.trim();
|
||||
|
||||
if (valueTrim.startsWith("[")) {
|
||||
// remove [ and ] - then convert to array
|
||||
return rawValue.replace(/[\[\]]/g, "").trim().split(", ").filter(str => str !== "");
|
||||
}
|
||||
|
||||
// split value by space and comma
|
||||
const valueAsArrayDouble = rawValue.split(" - ").map(str => str.trim()).filter(str => str !== "");
|
||||
|
||||
if (valueAsArrayDouble.length) {
|
||||
return valueAsArrayDouble;
|
||||
}
|
||||
|
||||
throw new Error(`${argumentName}: invalid parameter - you provided "${rawValue}". This option excepts an array in the format [val1, val2] or val1\/n - val2`);
|
||||
return rawValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user