From cf6a614f7a514e289425f09611c2d28de8c37a45 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Fri, 11 Feb 2022 13:19:16 -0800 Subject: [PATCH] feat: allow extra cli flags to be passed to unit testing executor --- packages/nx/src/executors/test/executor.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/nx/src/executors/test/executor.ts b/packages/nx/src/executors/test/executor.ts index 3d5052f90..04f7e9e36 100644 --- a/packages/nx/src/executors/test/executor.ts +++ b/packages/nx/src/executors/test/executor.ts @@ -83,11 +83,17 @@ export default async function testExecutor(options: TestBuilderSchema, context: nsOptions.push('--force'); } - // additional args after -- should be passed through - const argSeparator = process.argv.findIndex((arg) => arg === '--'); - let additionalArgs = []; - if (argSeparator >= 0) { - additionalArgs = process.argv.slice(argSeparator + 1); + // additional cli flags + // console.log('projectTargetCmdIndex:', projectTargetCmdIndex) + const additionalArgs = []; + if (process.argv.length > projectTargetCmdIndex + 1) { + const extraFlags = process.argv.slice(projectTargetCmdIndex + 1, process.argv.length); + for (const flag of extraFlags) { + if (!nsOptions.includes(flag) && !additionalArgs.includes(flag)) { + additionalArgs.push(flag); + } + } + // console.log('additionalArgs:', additionalArgs); } console.log('---');