Skip to content

Commit

Permalink
chore: minor code imprs
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Oct 26, 2024
1 parent 6d6499e commit 832cda3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/main/ts/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions src/main/ts/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ts/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
],
Expand Down

0 comments on commit 832cda3

Please sign in to comment.