fix(core): handle empty positional overrides

This commit is contained in:
Victor Savkin 2022-06-14 16:03:22 -04:00
parent 4a5bda60c8
commit 694510e211
No known key found for this signature in database
GPG Key ID: 39178FEB7698B817
2 changed files with 26 additions and 2 deletions

View File

@ -10,7 +10,7 @@ describe('splitArgs', () => {
base: 'sha1',
head: 'sha2',
notNxArg: true,
_: ['--override'],
override: true,
$0: '',
},
'affected',
@ -99,6 +99,7 @@ describe('splitArgs', () => {
{
files: [''],
notNxArg: true,
__positional_overrides__: [],
$0: '',
},
'affected',
@ -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(

View File

@ -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 = {};