From 943577993c04d22efe8e72f91e1574f827a09a83 Mon Sep 17 00:00:00 2001 From: Shigma <1700011071@pku.edu.cn> Date: Mon, 21 Feb 2022 23:06:00 +0800 Subject: [PATCH] fix(cli): duplicate execArgv options may break node --- packages/cli/src/start.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/start.ts b/packages/cli/src/start.ts index ee5a856447..e68948ce64 100644 --- a/packages/cli/src/start.ts +++ b/packages/cli/src/start.ts @@ -26,7 +26,15 @@ function toArg(key: string) { } function createWorker(options: Dict) { - const execArgv = Object.entries(options).flatMap(([key, value]) => key === '--' ? [] : [toArg(key), value]) + const execArgv = Object.entries(options).flatMap(([key, value]) => { + if (key === '--') return [] + key = toArg(key) + if (Array.isArray(value)) { + return value.flatMap(value => [key, value]) + } else { + return [key, value] + } + }) execArgv.push(...options['--']) child = fork(resolve(__dirname, 'worker'), [], {