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

feat: promise-based type() API that now supports treating text as command #42

Merged
merged 1 commit into from
Jul 22, 2023

Conversation

mkrl
Copy link
Owner

@mkrl mkrl commented Jul 22, 2023

Description

Convert existing type() API to be promise-based.
Instead of callback you can now pass a new argument isCommand (acts in the same way as in print, useful for terminal demos where you would create an effect of someone else typing the command).

The function now returns a promise resolving to true or false depending on user input interruption.

You might want to convert existing usages of type with callbacks in a similar matter:

Before

        terminal.type('text', 120, () => {
          if (!terminal.isProcessRunning) {
            terminal.print('Finished typing')
          }
        })

After

        terminal.type('text', 120)
          .then((finished) => {
            if (finished) {
              terminal.print('Finished typing')
            }
          })

or

        const finished = await terminal.type('text', 120)
        if (finished) {
            terminal.print('Finished typing')
        }

Pre-review checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation (if required)
  • My contribution is awesome

@mkrl mkrl added the enhancement New feature or request label Jul 22, 2023
@mkrl mkrl self-assigned this Jul 22, 2023
@mkrl mkrl merged commit 7570c9a into master Jul 22, 2023
2 checks passed
@mkrl mkrl deleted the promise-based-type-iscommand branch July 22, 2023 23:04
@github-actions
Copy link

🎉 This PR is included in version 1.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant