-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
stdin support #7
Conversation
Missing if (!input && process.stdin.isTTY) {
console.error('Input required');
process.exit(1);
} More info as to why this should be added |
opn(cli.input[0], cli.flags); | ||
} else if (process.stdin.isTTY) { | ||
console.error('Input required'); | ||
process.exit(1); |
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.
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.
Why not just do it like this?
const input = cli.input[0];
if (!input && process.stdin.isTTY) {
console.error('Input required');
process.exit(1);
}
if (input) {
opn(input, cli.flags);
} else {
// stdin stuff here
}
You have to show an error if input
is empty and process.stdin.isTTY
is true.
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.
Oh you are showing an error. Would rather see it extracted from the this if-else
block because this looks weird.
- handle input
- show error
- handle input
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.
done
Thanks @sonnyp ! Looks good to me. |
@sonnyp 💯 :D |
Thank you @sonnyp :) |
fixes #4