Skip to content

Commit

Permalink
fix(core): serialize properly override with object arg for command line
Browse files Browse the repository at this point in the history
Avoid outputting object args as [object Object].

Is related to nrwl#10808
  • Loading branch information
Lukasz Gawrys authored and FrozenPandaz committed Oct 27, 2022
1 parent 0f2b89b commit 83f9c3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/nx/src/utils/command-line-utils.spec.ts
Expand Up @@ -99,6 +99,7 @@ describe('splitArgs', () => {
{
files: [''],
notNxArg: true,
notNxArgObject: { objectKey: 'my value' },
__positional_overrides__: [],
$0: '',
},
Expand All @@ -107,8 +108,12 @@ describe('splitArgs', () => {
{} as any
).overrides
).toEqual({
__overrides_unparsed__: ['--notNxArg=true'],
__overrides_unparsed__: [
'--notNxArg=true',
'--notNxArgObject={"objectKey":"my value"}',
],
notNxArg: true,
notNxArgObject: { objectKey: 'my value' },
});
});

Expand Down
Expand Up @@ -7,7 +7,9 @@ export function serializeOverridesIntoCommandLine(args: {
r.push(
typeof args[a] === 'string' && args[a].includes(' ')
? `--${a}="${args[a].replace(/"/g, '"')}"`
: `--${a}=${args[a]}`
: `--${a}=${
typeof args[a] === 'object' ? JSON.stringify(args[a]) : args[a]
}`
);
}
});
Expand Down

0 comments on commit 83f9c3c

Please sign in to comment.