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

stdin support #7

Closed
wants to merge 1 commit into from
Closed

stdin support #7

wants to merge 1 commit into from

Conversation

sonnyp
Copy link
Contributor

@sonnyp sonnyp commented Jan 28, 2016

fixes #4

@SamVerschueren
Copy link
Contributor

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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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.

Copy link
Contributor

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.

  1. handle input
  2. show error
  3. handle input

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@SamVerschueren
Copy link
Contributor

Thanks @sonnyp ! Looks good to me.

@sonnyp
Copy link
Contributor Author

sonnyp commented Jan 29, 2016

@sindresorhus r?

@corysimmons
Copy link

@sonnyp 💯 :D

@sindresorhus sindresorhus mentioned this pull request Feb 10, 2016
@sindresorhus
Copy link
Owner

Thank you @sonnyp :)

@sonnyp sonnyp deleted the stdin-buffer branch February 10, 2016 11:30
sindresorhus added a commit that referenced this pull request Feb 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stdin support
5 participants