-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(core): ensure --help works properly with infix notation #32662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
View your CI Pipeline Execution ↗ for commit c411f22
☁️ Nx Cloud last updated this comment at |
@@ -112,7 +112,7 @@ export const commandsObject = yargs | |||
.command(resolveConformanceCommandObject()) | |||
.command(resolveConformanceCheckCommandObject()) | |||
.scriptName('nx') | |||
.help() | |||
.help(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabling the built-in yargs help handler with .help(false)
removes the automatic --help
flag processing for all commands. This appears to contradict the test expectations where Nx commands like nx graph --help
and nx affected --help
should display Nx's help output.
For this approach to work correctly, custom help handling logic needs to be implemented that:
- Preserves help functionality for native Nx commands
- Allows
--help
flags to pass through to underlying tools for infix commands
Without such custom logic, the tests in the PR will likely fail since they expect different help behavior depending on the command type. Consider implementing a custom help handler that differentiates between Nx commands and infix/run commands.
.help(false) | |
.help() | |
.middleware((argv) => { | |
// Custom help handling logic | |
if (argv.help) { | |
// For native Nx commands, show Nx help | |
// For infix/run commands, pass --help to the underlying tool | |
const command = argv._[0]; | |
if (!command || nxCommands.includes(command)) { | |
// This is a native Nx command, show help and exit | |
yargs.showHelp(); | |
process.exit(0); | |
} | |
// For infix commands, let the --help flag pass through | |
} | |
}) | |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
9a9c248
to
c411f22
Compare
Current Behavior
Running
nx run nx:test --help
andnx test nx --help
behave differentlyExpected Behavior
They are equivalent
Related Issue(s)
Fixes #