node-semver
node-semver copied to clipboard
[FEATURE] Allow piping into semver to read version
It would be very nice if we could do this:
node -v | semver -r ^5.4
Of course one could do semver $(node -v) but that only works in sh and not on Windows, which makes it bad for npm scripts.
I'm ok with it. Patch welcome, as long as it includes docs and test :)
Great. Is it possible to "detect" if there is data being piped from stdin or is a new command line flag needed?
You can check process.stdin.isTTY and also default to stdin if - is an option or if no options are provided. The stdin stream should be a white space delimited set of versions, probably?
You can check process.stdin.isTTY
thanks.
The stdin stream should be a white space delimited set of versions, probably?
I agree.
There is no engine field in package.json. What node versions have to be supported? I guess no arrow functions?
I guess the whitespace splitting will not work completely because one version can contain spaces, like ">=0.2 <=0.8". I guess the only option is to split by line breaks?
@felixfbecker Those are version ranges, not versions.
I'm imagining a thing like this:
get-list-of-versions-somehow | semver -r '>=2' > file-with-versions-gt-two.txt
So, the list of versions can be piped to stdin, but not the set of ranges
can we merge this?