cli: fix negated boolean options not removing implied options #56313
+124
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using negated options for boolean options that imply other options (e.g., --inspect-brk), the implied options are not removed as expected. This causes the implied option to remain active, leading to unexpected behavior.
shimaryuuheinoMac-mini:node shimaryuuhei$ node --inspect-brk --no-inspect-brk -e "console.log(\"foo\")" Debugger listening on ws://127.0.0.1:9229/67479127-5d17-4027-b514-70217b2fe102 For help, see: https://nodejs.org/en/docs/inspector foo
When using --no-inspect-brk, only the effect of the --inspect option remains.
This change ensures that when a negated option (e.g., --no-...) is used, any implied options are also removed. After this fix, the above example will no longer activate the implied options.
Alternative
Currently, the negated options affected by this change are not documented in the official CLI documentation: https://nodejs.org/api/cli.html
An alternative approach could be to remove these undocumented negated options entirely, ensuring no unexpected behavior arises from their usage.