Skip to content

Commit

Permalink
fix(core): handle empty positional overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Jun 14, 2022
1 parent 4a5bda6 commit 694510e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
23 changes: 22 additions & 1 deletion packages/nx/src/utils/command-line-utils.spec.ts
Expand Up @@ -10,7 +10,7 @@ describe('splitArgs', () => {
base: 'sha1',
head: 'sha2',
notNxArg: true,
_: ['--override'],
override: true,
$0: '',
},
'affected',
Expand Down Expand Up @@ -99,6 +99,7 @@ describe('splitArgs', () => {
{
files: [''],
notNxArg: true,
__positional_overrides__: [],
$0: '',
},
'affected',
Expand All @@ -111,6 +112,26 @@ describe('splitArgs', () => {
});
});

it('should split non nx specific arguments into target args (with positonal args)', () => {
expect(
splitArgsIntoNxArgsAndOverrides(
{
files: [''],
notNxArg: true,
__positional_overrides__: ['positional'],
$0: '',
},
'affected',
{} as any,
{} as any
).overrides
).toEqual({
_: ['positional'],
__overrides_unparsed__: ['positional', '--notNxArg=true'],
notNxArg: true,
});
});

it('should only use explicitly provided overrides', () => {
expect(
splitArgsIntoNxArgsAndOverrides(
Expand Down
5 changes: 4 additions & 1 deletion packages/nx/src/utils/command-line-utils.ts
Expand Up @@ -161,7 +161,10 @@ export function splitArgsIntoNxArgsAndOverrides(
}
}
const overridesFromMainArgs = {} as any;
if (args['__positional_overrides__']) {
if (
args['__positional_overrides__'] &&
args['__positional_overrides__'].length > 0
) {
overridesFromMainArgs['_'] = args['__positional_overrides__'];
}
const nxArgs: RawNxArgs = {};
Expand Down

1 comment on commit 694510e

@vercel
Copy link

@vercel vercel bot commented on 694510e Jun 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx.dev

Please sign in to comment.