1
0

v4.2.0 beta

- fixes for 550 folder issue
- updated excludes option format
This commit is contained in:
SamKirkland
2021-10-13 01:18:45 -05:00
parent 65c6a8f943
commit ba86a1bf13
8 changed files with 2124 additions and 2427 deletions
+6 -16
View File
@@ -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;
}