fix(cli): preserve hex positional args as strings by re-parsing argv#1187
Closed
dimitrovmaksim wants to merge 1 commit intographprotocol:mainfrom
Closed
fix(cli): preserve hex positional args as strings by re-parsing argv#1187dimitrovmaksim wants to merge 1 commit intographprotocol:mainfrom
dimitrovmaksim wants to merge 1 commit intographprotocol:mainfrom
Conversation
gluegun uses yargs-parser internally which converts hex strings (e.g. 0x0, 0x...0010) to numbers before commands see them, making the conversion irreversible. This caused normalizePOIParams to silently skip zero-POI normalization (0 === '0' is false) and corrupted non-zero hex POI values. Add getRawPositionalArgs() which re-parses process.argv with parse-numbers disabled and slices off the subcommand prefix to recover the original strings. Apply it across all 10 commands that use parameters.array.
3ca22c8 to
02f0208
Compare
Member
Author
|
closing in favor of #1188 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
gluegun uses yargs-parser internally to parse CLI arguments. yargs-parser converts hex strings to numbers before the command handlers see them.
This caused two bugs in v0.25.6/7:
Note: v0.25.4 used loose equality (== '0') which accidentally caught the integer case, but the refactor to normalizePOIParams in v0.25.6 switched to ===, reintroducing the bug.
What this PR does:
Adds
getRawPositionalArgs()incommand-helpers.tswhich re-parsesprocess.argvwithparse-numbers: false, bypassing yargs-parser's number coercion.