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

fix: only set timeout for TTY #967

Merged
merged 3 commits into from
Feb 22, 2024
Merged

Conversation

mdonnalley
Copy link
Contributor

Only set a timeout for a prompt if process.stdin.TTY is truthy

QA

  1. checkout this branch and yarn build
  2. yarn && yarn build in plugin-not-found directory
  3. yarn link @oclif/core in plugin-not-found directory
  4. sf plugins link --no-install in plugin-not-found directory
  5. Test the following:

Standard misspelled command scenario. Prompt should timeout after 10 seconds.

❯ time sf verson
 ›   Warning: @oclif/plugin-not-found is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used
 ›   instead.
 ›   Warning: verson is not a sf command.
Did you mean version? [y/n]:

 ›   Error: Run sf help for a list of available commands.
sf verson  0.55s user 0.09s system 6% cpu 10.429 total

Piping answer to prompt. Should not wait for timeout.

❯ echo y | sf verson
 ›   Warning: @oclif/plugin-not-found is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used
 ›   instead.
 ›   Warning: verson is not a sf command.
Did you mean version? [y/n]: y
@salesforce/cli/2.28.6 darwin-arm64 node-v20.11.0

Redirecting stdin to /dev/null should exit immediately with 0 exit code

❯ sf verson </dev/null
 ›   Warning: @oclif/plugin-not-found is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used
 ›   instead.
 ›   Warning: verson is not a sf command.
Did you mean version? [y/n]: %

❯ echo $?
0

@W-15100925@

iowillhoit
iowillhoit previously approved these changes Feb 22, 2024
Copy link
Contributor

@iowillhoit iowillhoit left a comment

Choose a reason for hiding this comment

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

Looks good. Tested locally and exit codes are correct

@iowillhoit iowillhoit merged commit 9a39d7e into main Feb 22, 2024
59 checks passed
@iowillhoit iowillhoit deleted the mdonnalley/no-timeout-in-non-tty branch February 22, 2024 19:11
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.

2 participants