diff --git a/packages/nx/src/utils/params.spec.ts b/packages/nx/src/utils/params.spec.ts index f36128497ff7b..8e286fd4db281 100644 --- a/packages/nx/src/utils/params.spec.ts +++ b/packages/nx/src/utils/params.spec.ts @@ -708,6 +708,54 @@ describe('params', () => { expect(params).toEqual({ a: './somepath' }); }); + + it('should set unparsed overrides', () => { + const params = { __overrides_unparsed__: ['one'] }; + convertSmartDefaultsIntoNamedParams( + params, + { + properties: { + unparsed: { + type: 'array', + items: { + type: 'string', + }, + $default: { + $source: 'unparsed', + }, + }, + }, + }, + null, + null + ); + + expect(params).toEqual({ unparsed: ['one'] }); + }); + + it('should set unparsed overrides (missing)', () => { + const params = {}; + convertSmartDefaultsIntoNamedParams( + params, + { + properties: { + unparsed: { + type: 'array', + items: { + type: 'string', + }, + $default: { + $source: 'unparsed', + }, + }, + }, + }, + null, + null + ); + + expect(params).toEqual({ unparsed: [] }); + }); }); describe('validateOptsAgainstSchema', () => { diff --git a/packages/nx/src/utils/params.ts b/packages/nx/src/utils/params.ts index c6ae2df13addf..f29efba74e604 100644 --- a/packages/nx/src/utils/params.ts +++ b/packages/nx/src/utils/params.ts @@ -631,7 +631,7 @@ export function convertSmartDefaultsIntoNamedParams( usedPositionalArgs[v.$default.index] = true; opts[k] = coerceType(v, argv[v.$default.index]); } else if (v.$default !== undefined && v.$default.$source === 'unparsed') { - opts[k] = opts['__overrides_unparsed__']; + opts[k] = opts['__overrides_unparsed__'] || []; } else if ( opts[k] === undefined && v.$default !== undefined &&