From 187f2a13ae085d28b51ab92ea60152473d20c011 Mon Sep 17 00:00:00 2001 From: Victor Savkin Date: Fri, 6 Jan 2023 09:37:25 -0500 Subject: [PATCH] fix(misc): fix --help for generators and executors --- packages/nx/bin/init-local.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/nx/bin/init-local.ts b/packages/nx/bin/init-local.ts index 750ebe8f78..7d79ec0970 100644 --- a/packages/nx/bin/init-local.ts +++ b/packages/nx/bin/init-local.ts @@ -23,7 +23,10 @@ export function initLocal(workspace: WorkspaceTypeAndRoot) { return; } - if (isKnownCommand()) { + const command = process.argv[2]; + if (command === 'run' || command === 'g' || command === 'generate') { + commandsObject.parse(process.argv.slice(2)); + } else if (isKnownCommand(command)) { const newArgs = rewriteTargetsAndProjects(process.argv); const help = newArgs.indexOf('--help'); const split = newArgs.indexOf('--'); @@ -89,7 +92,7 @@ function wrapIntoQuotesIfNeeded(arg: string) { return arg.indexOf(':') > -1 ? `"${arg}"` : arg; } -function isKnownCommand() { +function isKnownCommand(command: string) { const commands = [ ...Object.keys( (commandsObject as any) @@ -106,11 +109,7 @@ function isKnownCommand() { 'clear-cache', 'help', ]; - return ( - !process.argv[2] || - process.argv[2].startsWith('-') || - commands.indexOf(process.argv[2]) > -1 - ); + return !command || command.startsWith('-') || commands.indexOf(command) > -1; } function shouldDelegateToAngularCLI() {