Skip to content

Commit

Permalink
fix(core): move affected positional arguments args back to util (#12994)
Browse files Browse the repository at this point in the history
(cherry picked from commit d6c4547)
  • Loading branch information
FrozenPandaz committed Nov 4, 2022
1 parent 59a0cec commit e80a2b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
17 changes: 0 additions & 17 deletions packages/nx/src/command-line/nx-commands.ts
Expand Up @@ -524,23 +524,6 @@ function withAffectedOptions(yargs: yargs.Argv): yargs.Argv {
untracked: ['uncommitted', 'files', 'base', 'head', 'all'],
uncommitted: ['files', 'untracked', 'base', 'head', 'all'],
all: ['files', 'untracked', 'uncommitted', 'base', 'head'],
})
.check((nxArgs) => {
if (
!nxArgs.files &&
!nxArgs.uncommitted &&
!nxArgs.untracked &&
!nxArgs.base &&
!nxArgs.head &&
!nxArgs.all &&
nxArgs._ &&
nxArgs._.length >= 3
) {
throw new Error(
`Nx no longer supports using positional arguments for base and head. Please use --base and --head instead.`
);
}
return true;
});
}

Expand Down
15 changes: 15 additions & 0 deletions packages/nx/src/utils/command-line-utils.ts
Expand Up @@ -100,6 +100,21 @@ export function splitArgsIntoNxArgsAndOverrides(
});
}

if (
!nxArgs.files &&
!nxArgs.uncommitted &&
!nxArgs.untracked &&
!nxArgs.base &&
!nxArgs.head &&
!nxArgs.all &&
overrides._ &&
overrides._.length >= 2
) {
throw new Error(
`Nx no longer supports using positional arguments for base and head. Please use --base and --head instead.`
);
}

// Allow setting base and head via environment variables (lower priority then direct command arguments)
if (!nxArgs.base && process.env.NX_BASE) {
nxArgs.base = process.env.NX_BASE;
Expand Down

0 comments on commit e80a2b7

Please sign in to comment.