Allow piping into semver to read versions#161
Allow piping into semver to read versions#161richardgarnier wants to merge 5 commits intonpm:mainfrom richardgarnier:master
Conversation
| break | ||
| case "-h": case "--help": case "-?": | ||
| return help() | ||
| break |
There was a problem hiding this comment.
I guess the break here was missing. This is not the main purpose of the patch though.
There was a problem hiding this comment.
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
versionsarray 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.1is accepted.NB2 : testing relies on comparing the output of the version without piping, and the version with piping.