Skip to content

Commit

Permalink
fix(core): forward args provided to the nx add command to the invoked…
Browse files Browse the repository at this point in the history
… init generator (#22855)

(cherry picked from commit 125c1d2)
  • Loading branch information
leosvelperez authored and FrozenPandaz committed Apr 18, 2024
1 parent ed39d8c commit 7ac5ca5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/nx/src/command-line/add/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ async function initializePlugin(
await runNxAsync(
`g ${pkgName}:${initGenerator} --keepExistingVersions${
updatePackageScripts ? ' --updatePackageScripts' : ''
}${
options.__overrides_unparsed__.length
? ' ' + options.__overrides_unparsed__.join(' ')
: ''
}`,
{
silent: !options.verbose,
Expand Down
9 changes: 8 additions & 1 deletion packages/nx/src/command-line/add/command-object.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { CommandModule } from 'yargs';
import { withOverrides } from '../yargs-utils/shared-options';

export interface AddOptions {
packageSpecifier: string;
updatePackageScripts?: boolean;
verbose?: boolean;
__overrides_unparsed__: string[];
}

export const yargsAddCommand: CommandModule<
Expand All @@ -14,6 +16,10 @@ export const yargsAddCommand: CommandModule<
describe: 'Install a plugin and initialize it.',
builder: (yargs) =>
yargs
.parserConfiguration({
'strip-dashed': true,
'unknown-options-as-args': true,
})
.positional('packageSpecifier', {
type: 'string',
description:
Expand Down Expand Up @@ -41,5 +47,6 @@ export const yargsAddCommand: CommandModule<
'$0 add @nx/react@17.0.0',
'Install version `17.0.0` of the `@nx/react` package and run its `@nx/react:init` generator'
) as any,
handler: (args) => import('./add').then((m) => m.addHandler(args)),
handler: (args) =>
import('./add').then((m) => m.addHandler(withOverrides(args))),
};

0 comments on commit 7ac5ca5

Please sign in to comment.