Skip to content
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

[FEATURE] Allow piping into semver to read version #149

Open
felixfbecker opened this issue Jan 12, 2016 · 7 comments
Open

[FEATURE] Allow piping into semver to read version #149

felixfbecker opened this issue Jan 12, 2016 · 7 comments
Labels
cli referencing the semver cli Enhancement new feature or improvement

Comments

@felixfbecker
Copy link

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.

@isaacs
Copy link
Contributor

isaacs commented Jan 12, 2016

I'm ok with it. Patch welcome, as long as it includes docs and test :)

@felixfbecker
Copy link
Author

Great. Is it possible to "detect" if there is data being piped from stdin or is a new command line flag needed?

@isaacs
Copy link
Contributor

isaacs commented Jan 12, 2016

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?

@felixfbecker
Copy link
Author

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?

@felixfbecker
Copy link
Author

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?

@isaacs
Copy link
Contributor

isaacs commented Jan 15, 2016

@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

isaacs pushed a commit that referenced this issue Jul 8, 2017
isaacs pushed a commit that referenced this issue Jul 8, 2017
@gWOLF3
Copy link

gWOLF3 commented May 20, 2020

can we merge this?

@darcyclarke darcyclarke changed the title Allow piping into semver to read version [FEATURE] Allow piping into semver to read version Jul 28, 2022
@darcyclarke darcyclarke added the Enhancement new feature or improvement label Jul 28, 2022
@lukekarrys lukekarrys added the cli referencing the semver cli label Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli referencing the semver cli Enhancement new feature or improvement
Projects
None yet
Development

No branches or pull requests

6 participants
@isaacs @darcyclarke @lukekarrys @felixfbecker @gWOLF3 and others