From 36abf540e27e7503f4f1c09203f0554e71d2be37 Mon Sep 17 00:00:00 2001 From: Mark McCulloh Date: Wed, 5 Jul 2023 11:29:08 -0400 Subject: [PATCH 1/2] fix(core): ensure target-only argument is rewritten correctly --- packages/nx/bin/init-local.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nx/bin/init-local.ts b/packages/nx/bin/init-local.ts index 9ff75d7b4a3f1..648ff76e5c8cd 100644 --- a/packages/nx/bin/init-local.ts +++ b/packages/nx/bin/init-local.ts @@ -91,7 +91,7 @@ function rewritePositionalArguments(args: string[]) { for (let i = 2; i < args.length; i++) { if (!args[i].startsWith('-')) { relevantPositionalArgs.push(args[i]); - if (relevantPositionalArgs.length === 2) { + if (relevantPositionalArgs.length <= 2) { rest.push(...args.slice(i + 1)); break; } From 99801e080ca11c0acaed4175d9e5cbb418327c0e Mon Sep 17 00:00:00 2001 From: Mark McCulloh Date: Wed, 5 Jul 2023 11:52:06 -0400 Subject: [PATCH 2/2] fix(core): trust -- as an explicit marker for argument forwarding --- packages/nx/bin/init-local.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/nx/bin/init-local.ts b/packages/nx/bin/init-local.ts index 648ff76e5c8cd..5fe2056b1e9bf 100644 --- a/packages/nx/bin/init-local.ts +++ b/packages/nx/bin/init-local.ts @@ -89,9 +89,12 @@ function rewritePositionalArguments(args: string[]) { const relevantPositionalArgs = []; const rest = []; for (let i = 2; i < args.length; i++) { - if (!args[i].startsWith('-')) { + if (args[i] === '--') { + rest.push(...args.slice(i + 1)); + break; + } else if (!args[i].startsWith('-')) { relevantPositionalArgs.push(args[i]); - if (relevantPositionalArgs.length <= 2) { + if (relevantPositionalArgs.length === 2) { rest.push(...args.slice(i + 1)); break; }