From 0ce7ce6b51679313e31728fac166480313300e63 Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Mon, 25 Apr 2022 23:02:12 -0400 Subject: [PATCH] fix(core): align yargs options in workspace-generator with generic opts passed to other commands (#9953) --- packages/nx/src/command-line/nx-commands.ts | 12 +++++++----- packages/nx/src/command-line/workspace-generators.ts | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/nx/src/command-line/nx-commands.ts b/packages/nx/src/command-line/nx-commands.ts index e129f9025ecf8..bb964bc4a065c 100644 --- a/packages/nx/src/command-line/nx-commands.ts +++ b/packages/nx/src/command-line/nx-commands.ts @@ -15,6 +15,12 @@ const daemonHelpOutput = generateDaemonHelpOutput(isGenerateDocsProcess); // Ensure that the output takes up the available width of the terminal yargs.wrap(yargs.terminalWidth()); +export const parserConfiguration: Partial = { + 'strip-dashed': true, + // allow parsing --env.SOME_ARG for cypress cli env args + 'dot-notation': true, +}; + /** * Exposing the Yargs commands object so the documentation generator can * parse it. The CLI will consume it and call the `.argv` to bootstrapped @@ -23,11 +29,7 @@ yargs.wrap(yargs.terminalWidth()); * le executed correctly. */ export const commandsObject = yargs - .parserConfiguration({ - 'strip-dashed': true, - // allow parsing --env.SOME_ARG for cypress cli env args - 'dot-notation': true, - }) + .parserConfiguration(parserConfiguration) .usage( ` ${chalk.bold('Smart, Fast and Extensible Build System')}` + diff --git a/packages/nx/src/command-line/workspace-generators.ts b/packages/nx/src/command-line/workspace-generators.ts index 57cb9619e8570..4e42dd336b741 100644 --- a/packages/nx/src/command-line/workspace-generators.ts +++ b/packages/nx/src/command-line/workspace-generators.ts @@ -13,6 +13,7 @@ import { readJsonFile, writeJsonFile } from '../utils/fileutils'; import { logger } from '../utils/logger'; import { getPackageManagerCommand } from '../utils/package-manager'; import { normalizePath } from '../utils/path'; +import { parserConfiguration } from './nx-commands'; const rootDirectory = workspaceRoot; const toolsDir = path.join(rootDirectory, 'tools'); @@ -160,6 +161,7 @@ function parseOptions( default: { interactive: true, }, + configuration: parserConfiguration, }); parsed['generator'] = `${collectionFile}:${parsed['_'][0]}`; parsed['_'] = parsed['_'].slice(1);