Skip to content

Conversation

mdvorak
Copy link
Contributor

@mdvorak mdvorak commented Apr 7, 2025

Don't use "false" string as true value.

For example release-it --git.commit=false was parsed as true, because string "false" is non-empty.

Copy link

pkg-pr-new bot commented Apr 7, 2025

Open in StackBlitz

npm i https://pkg.pr.new/release-it@1215

commit: 12910a3

Copy link
Collaborator

@webpro webpro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Michal

The idea is that you can negate using --no- e.g. --no-git.commit (https://www.npmjs.com/package/yargs-parser#boolean-negation)

It's cool if we'd be able to use =false (and =0?) to negate as well, but it is not documented: https://www.npmjs.com/package/yargs-parser - any chance you could squeeze in a test somewhere?

@mdvorak
Copy link
Contributor Author

mdvorak commented Apr 8, 2025

Thanks Michal

The idea is that you can negate using --no- e.g. --no-git.commit (https://www.npmjs.com/package/yargs-parser#boolean-negation)

It's cool if we'd be able to use =false (and =0?) to negate as well, but it is not documented: https://www.npmjs.com/package/yargs-parser - any chance you could squeeze in a test somewhere?

Actually, both are supported by yargs, where --no flags being an extra feature (can be disabled). When using in scripts, its often more readable to do --foo=$FOO_ENABLED then building FOO_ARG variable. Yargs is sadly lacking documentation in some regards.

About unit test, thats good idea.

@webpro
Copy link
Collaborator

webpro commented Apr 8, 2025

Thanks Michal
The idea is that you can negate using --no- e.g. --no-git.commit (https://www.npmjs.com/package/yargs-parser#boolean-negation)
It's cool if we'd be able to use =false (and =0?) to negate as well, but it is not documented: https://www.npmjs.com/package/yargs-parser - any chance you could squeeze in a test somewhere?

Actually, both are supported by yargs, where --no flags being an extra feature (can be disabled). When using in scripts, its often more readable to do --foo=$FOO_ENABLED then building FOO_ARG variable. Yargs is sadly lacking documentation in some regards.

Good point, haven't used it that way yet.

About unit test, thats good idea.

Thanks!

@mdvorak
Copy link
Contributor Author

mdvorak commented Apr 8, 2025

I've refactored bin to args.js, so it is testable. Testing whole bin js is problematic (but can be done).

@webpro
Copy link
Collaborator

webpro commented Apr 8, 2025

This is great! Thanks.

@webpro webpro merged commit d87fd39 into release-it:main Apr 8, 2025
10 checks passed
@mdvorak mdvorak deleted the parse-booleans branch April 8, 2025 15:08
@webpro
Copy link
Collaborator

webpro commented Apr 9, 2025

🚀 This pull request is included in v19.0.0-next.4. See Release 19.0.0-next.4 for release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants