Skip to content

Commit

Permalink
fix(core): handle an edge case where overrides_unparsed is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Jun 15, 2022
1 parent 986b053 commit f469fd1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
48 changes: 48 additions & 0 deletions packages/nx/src/utils/params.spec.ts
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/utils/params.ts
Expand Up @@ -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 &&
Expand Down

1 comment on commit f469fd1

@vercel
Copy link

@vercel vercel bot commented on f469fd1 Jun 15, 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-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx.dev

Please sign in to comment.