diff --git a/packages/nx/src/utils/command-line-utils.spec.ts b/packages/nx/src/utils/command-line-utils.spec.ts index c68058a47f437..78794ca4c0940 100644 --- a/packages/nx/src/utils/command-line-utils.spec.ts +++ b/packages/nx/src/utils/command-line-utils.spec.ts @@ -161,6 +161,24 @@ describe('splitArgs', () => { }); }); + it('should split projects when it is a string', () => { + expect( + splitArgsIntoNxArgsAndOverrides( + { + projects: 'aaa,bbb', + __overrides_unparsed__: [], + $0: '', + }, + 'run-many', + {} as any, + {} as any + ).nxArgs + ).toEqual({ + projects: ['aaa', 'bbb'], + skipNxCache: false, + }); + }); + it('should set base and head based on environment variables in affected mode, if they are not provided directly on the command', () => { const originalNxBase = process.env.NX_BASE; process.env.NX_BASE = 'envVarSha1'; diff --git a/packages/nx/src/utils/command-line-utils.ts b/packages/nx/src/utils/command-line-utils.ts index d806ca7e4c57c..eed9b713569f3 100644 --- a/packages/nx/src/utils/command-line-utils.ts +++ b/packages/nx/src/utils/command-line-utils.ts @@ -81,8 +81,11 @@ export function splitArgsIntoNxArgsAndOverrides( delete (nxArgs as any).__overrides_unparsed__; if (mode === 'run-many') { - if (!nxArgs.projects) { - nxArgs.projects = []; + const args = nxArgs as any; + if (!args.projects) { + args.projects = []; + } else if (typeof args.projects === 'string') { + args.projects = args.projects.split(','); } }