-
Notifications
You must be signed in to change notification settings - Fork 492
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
Allow piping into semver to read versions #161
Conversation
@@ -56,6 +75,7 @@ function main () { | |||
break | |||
case "-h": case "--help": case "-?": | |||
return help() | |||
break |
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.
I guess the break here was missing. This is not the main purpose of the patch though.
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.
A break isn't strictly necessary here, since the return
is just as effective at ending the block. But if a linter or something is complaining about it, whatever.
Well that test was embarrassing... sorry |
This is ok, and seems to work, but it seems like it'd be better to open stdin, and parse/filter each version as lines are read. That way it could be done interactively. I could see this being really handy if you want to test out whether a given range works with various versions. You can use node's builtin |
Oh, I just realized something about this. This means that any programs that That's probably surprising. One approach would be to only read the stdin pipe if |
Closing this one for now since it still has work to be done. |
This is a patch for #149.
Before entering the main, we check if the process is piped. If so then we fill the
versions
array and then we launch the main. In order to fill the array, we split on spaces.NB : versions can be accepted both from the pipe and as arguments.
For example
echo 1.0.0 | semver -r '>=1' 1.1.1
is accepted.NB2 : testing relies on comparing the output of the version without piping, and the version with piping.