diff --git a/packages/nx/src/utils/command-line-utils.spec.ts b/packages/nx/src/utils/command-line-utils.spec.ts index c68058a47f437..5c76051a86364 100644 --- a/packages/nx/src/utils/command-line-utils.spec.ts +++ b/packages/nx/src/utils/command-line-utils.spec.ts @@ -20,6 +20,7 @@ describe('splitArgs', () => { base: 'sha1', head: 'sha2', skipNxCache: false, + parallel: 3, }); }); @@ -51,6 +52,7 @@ describe('splitArgs', () => { ).toEqual({ base: 'main', skipNxCache: false, + parallel: 3, }); }); @@ -68,6 +70,7 @@ describe('splitArgs', () => { ).toEqual({ base: 'develop', skipNxCache: false, + parallel: 3, }); }); @@ -85,6 +88,7 @@ describe('splitArgs', () => { ).toEqual({ base: 'main', skipNxCache: false, + parallel: 3, }); }); @@ -181,6 +185,7 @@ describe('splitArgs', () => { base: 'envVarSha1', head: 'envVarSha2', skipNxCache: false, + parallel: 3, }); expect( @@ -198,6 +203,7 @@ describe('splitArgs', () => { base: 'envVarSha1', head: 'directlyOnCommandSha1', skipNxCache: false, + parallel: 3, }); expect( @@ -215,6 +221,7 @@ describe('splitArgs', () => { base: 'directlyOnCommandSha2', head: 'envVarSha2', skipNxCache: false, + parallel: 3, }); // Reset process data @@ -238,7 +245,21 @@ describe('splitArgs', () => { expect(parallel).toEqual(5); }); - it('should default to 3', () => { + it('should default to 3 when not specified', () => { + const parallel = splitArgsIntoNxArgsAndOverrides( + { + $0: '', + __overrides_unparsed__: [], + }, + 'affected', + {} as any, + {} as any + ).nxArgs.parallel; + + expect(parallel).toEqual(3); + }); + + it('should default to 3 when used with no value specified', () => { const parallel = splitArgsIntoNxArgsAndOverrides( { $0: '', diff --git a/packages/nx/src/utils/command-line-utils.ts b/packages/nx/src/utils/command-line-utils.ts index 0794e5bd9ed65..e68efaea3e89f 100644 --- a/packages/nx/src/utils/command-line-utils.ts +++ b/packages/nx/src/utils/command-line-utils.ts @@ -170,7 +170,8 @@ export function splitArgsIntoNxArgsAndOverrides( } else if ( args['parallel'] === 'true' || args['parallel'] === true || - args['parallel'] === '' + args['parallel'] === '' || + args['parallel'] === undefined ) { nxArgs['parallel'] = Number( nxArgs['maxParallel'] || nxArgs['max-parallel'] || 3