Odd versions cause the module to crash
GabrielLomba opened this issue · 5 comments
Hi.
I have faced an issue with this module recently where a computer had some really odd yarn version (yarn --version returned "0.32+git") and this line ended up throwing a TypeError: Invalid Version: 0.32+git
.
Can we start checking for valid versions on commands output? I can submit a PR with this fix, if you want.
Hey @GabrielLomba, having some safety around this makes sense. I'd definitely appreciate and accept a PR for this.
That is indeed bad, I'm shocked that yarn would output a non-semver version. What would be the desired behaviour here?
We could:
- abort with a nicer message
- have the check fail with a message that the tool in question returned a non-semver version
- normalize the missing parts to
.0
so that0.32+git
would be considered0.32.0+git
, and0+git
would be0.0.0+git
Personally, I tend towards 2 in order to make these cases obvious. Behaviour 3, however, would probably be close to the intuitive expectation of most users.
We could combine 2 and 3 by introducing a flag like --loose
to switch from 2 to 3.
@parshap What do you think?
Good point about intuitive expectations. That said, I agree 2 makes most sense. I don't think there's enough need for this to warrant the complexity of 3 or a --loose
flag.
Agree with @parshap . Option 2 will make the error apparent right away and force the user in question to do something about it, not leading to some undefined state if we proceed with parsing non-semver versions.
I will probably send the PR this weekend.