Skip to content

Commit

Permalink
feat: support string array for ArgParams (#120)
Browse files Browse the repository at this point in the history
* feat: support string array for ArgParams

Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>

* refactor: address lint errors and improve readability

Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>

* refactor: remove code duplication, optimize arg reduce fn

Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>

---------

Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>
  • Loading branch information
traeok committed Jun 13, 2024
1 parent b0c30a3 commit 086e39d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,17 @@ export default class VSCodeWorkerService implements Services.ServiceInstance {

const binary = path.join(__dirname, 'chromium', `index.${process.platform === 'win32' ? 'exe' : 'js'}`)
const args = Object.entries({ ...customArgs, ...this._vscodeOptions.vscodeArgs }).reduce(
(prev, [key, value]) => [
...prev,
`--${decamelize(key, { separator: '-' })}${getValueSuffix(value)}`
],
(prev, [key, value]) => {
const decamelizedKey = decamelize(key, { separator: '-' })
if (Array.isArray(value)) {
const expandedArgs = value.map(
(val) => `--${decamelizedKey}${getValueSuffix(val)}`
)
return [...prev, ...expandedArgs]
}

return [...prev, `--${decamelizedKey}${getValueSuffix(value)}`]
},
[] as string[]
)

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface ServerOptions {
port: number
}

export type ArgsParams = Record<string, string | boolean>
export type ArgsParams = Record<string, string | string[] | boolean>

/**
* wdio-vscode-service options
Expand Down

0 comments on commit 086e39d

Please sign in to comment.