-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
check if there is any stdin to get #1
Comments
I usually do the check in my own code as I want different behavior: https://github.com/sindresorhus/gzip-size/blob/ac77bbe818b2fc705ba38c5326caf4f0d6b90b6b/cli.js#L39-L48 What should it return when it's not tty though? Nothing, null, empty string? |
🐹 |
haha sorry, I guess probably an empty string / empty buffer, since that's what you'd be working with in the lib anyway. |
@matthewmueller Like d2c098e, right? |
yep, looks good. thanks! |
Is this fix really right? |
@shinnn Nothing is stopping you from doing that now. This is just a shortcut. |
The example script in README doesn't work with v3.0.1. // example.js
var stdin = require('get-stdin');
stdin(function (data) {
console.log(data);
}); $ echo unicorns | node example.js
We expect to see |
Shouldn't it be |
@sindresorhus @kevva Thanks! |
I was surprise to find this very popular module doesn't support TTY. This would be very useful to have for a CLI program, and is easy enough to add (i.e., by listening for ^z or ^d as EOT markers in the input). Would you be willing to entertain a PR? |
@moos I'm not really sure what you're asking for. Can you elaborate or provide an example of what you're trying to achieve? |
I'd like to be able to run a program and have it read from the keyboard as well as a pipe. getStdin works for: $ echo 'abc' | foo - but not for: $ foo - The dash in 'foo -' tells it to read STDIN (by convention only). Hope that's clear. This can be done in a backward compatible way and I think it's a useful feature to have. |
Looks like
process.stdin.isTTY
checks to see if there is any data to get.Otherwise, this function just hangs.
The text was updated successfully, but these errors were encountered: