From 2b045e055b17b9637a1638bddd4bce7cce237d3f Mon Sep 17 00:00:00 2001 From: Caleb Ukle Date: Thu, 14 Apr 2022 09:50:09 -0500 Subject: [PATCH] fix(core): allow parsing dot notation cli args (#9812) parse dot notation cli args for env args passed to cypress executor to override cypress.env.json values. i.e. nx e2e project --env.API_URL=localhost:1234 will now correctly give cypress e2e args to override the cypress.env.json values ISSUES CLOSED: #9764 --- .../nx/src/command-line/nx-commands.spec.ts | 24 +++++++++++++++++++ packages/nx/src/command-line/nx-commands.ts | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 packages/nx/src/command-line/nx-commands.spec.ts diff --git a/packages/nx/src/command-line/nx-commands.spec.ts b/packages/nx/src/command-line/nx-commands.spec.ts new file mode 100644 index 0000000000000..d37b249e91a66 --- /dev/null +++ b/packages/nx/src/command-line/nx-commands.spec.ts @@ -0,0 +1,24 @@ +import { commandsObject } from 'nx/src/command-line/nx-commands'; + +describe('nx-commands', () => { + it('should parse dot notion cli args', () => { + const actual = commandsObject.parse( + 'nx e2e project-e2e --env.NX_API_URL=http://localhost:4200 --abc.123.xyx=false --a.b=3' + ); + expect(actual).toEqual( + expect.objectContaining({ + abc: { + '123': { + xyx: 'false', + }, + }, + a: { + b: 3, + }, + env: { + NX_API_URL: 'http://localhost:4200', + }, + }) + ); + }); +}); diff --git a/packages/nx/src/command-line/nx-commands.ts b/packages/nx/src/command-line/nx-commands.ts index 2c20ceb1bed7a..92fb3257ab365 100644 --- a/packages/nx/src/command-line/nx-commands.ts +++ b/packages/nx/src/command-line/nx-commands.ts @@ -25,7 +25,8 @@ yargs.wrap(yargs.terminalWidth()); export const commandsObject = yargs .parserConfiguration({ 'strip-dashed': true, - 'dot-notation': false, + // allow parsing --env.SOME_ARG for cypress cli env args + 'dot-notation': true, }) .usage( `