From 832cda3fc516006e671084fdfc697bbab4152a9b Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Sat, 26 Oct 2024 20:58:20 +0300 Subject: [PATCH] chore: minor code imprs --- src/main/ts/cli.ts | 3 +-- src/main/ts/util.ts | 11 +++++------ src/test/ts/util.ts | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/ts/cli.ts b/src/main/ts/cli.ts index 051b4ed..f870ff2 100644 --- a/src/main/ts/cli.ts +++ b/src/main/ts/cli.ts @@ -14,8 +14,7 @@ const parseMultipleValueArg = ( return value } - const previousArray = Array.isArray(previous) ? previous : [previous] - return previousArray.concat([value]) + return [previous, value].flat() } const env = process.env diff --git a/src/main/ts/util.ts b/src/main/ts/util.ts index e57eb7c..cb84e70 100644 --- a/src/main/ts/util.ts +++ b/src/main/ts/util.ts @@ -71,16 +71,15 @@ export const formatFlags = (flags: TFlags, ...picklist: string[]): string[] => const flag = formatFlag(key) if (checkValue(key, value, omitlist, picklist)) { - if (!Array.isArray(value)) { + if (Array.isArray(value)) { + value.forEach((val) => { + memo.push(flag, String(val)) + }) + } else { memo.push(flag) - if (value !== true) { memo.push(String(value)) } - } else { - value.forEach((val) => { - memo.push(flag, String(val)) - }) } } diff --git a/src/test/ts/util.ts b/src/test/ts/util.ts index d91d091..a308c9f 100644 --- a/src/test/ts/util.ts +++ b/src/test/ts/util.ts @@ -91,7 +91,7 @@ describe('util', () => { ], [{ exclude: [] }, ['exclude'], []], [ - { exclude: ['@scope/package'] }, + { exclude: ['@scope/package'] }, // eslint-disable-line sonarjs/no-duplicate-string ['exclude'], ['--exclude', '@scope/package'], ],