From 086e39dc8afa2384866af3cda67b567b8c0212f7 Mon Sep 17 00:00:00 2001 From: Trae Yelovich Date: Thu, 13 Jun 2024 14:00:10 -0400 Subject: [PATCH] feat: support string array for ArgParams (#120) * feat: support string array for ArgParams Signed-off-by: Trae Yelovich * refactor: address lint errors and improve readability Signed-off-by: Trae Yelovich * refactor: remove code duplication, optimize arg reduce fn Signed-off-by: Trae Yelovich --------- Signed-off-by: Trae Yelovich --- src/service.ts | 15 +++++++++++---- src/types.ts | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/service.ts b/src/service.ts index b6134a20..a37226f9 100644 --- a/src/service.ts +++ b/src/service.ts @@ -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[] ) diff --git a/src/types.ts b/src/types.ts index 673f01c1..77a3ed62 100644 --- a/src/types.ts +++ b/src/types.ts @@ -52,7 +52,7 @@ export interface ServerOptions { port: number } -export type ArgsParams = Record +export type ArgsParams = Record /** * wdio-vscode-service options