feat: add AbortSignal support
Fixes https://github.com/SBoudrias/Inquirer.js/issues/1521
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Please upload report for BASE (
main@80c6c57). Learn more about missing BASE report.
Additional details and impacted files
@@ Coverage Diff @@
## main #1524 +/- ##
=======================================
Coverage ? 98.25%
=======================================
Files ? 37
Lines ? 2403
Branches ? 653
=======================================
Hits ? 2361
Misses ? 36
Partials ? 6
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I took the liberty to:
- Add more documentation and update the timeout demo. AbortSignal is a much better interface, so I want to make sure we surface it :)
- Refactored the cleanup logic in
@inquirer/core- it wasn't great, and I felt it caused some struggle. It'd have been simpler withoutpromise.cancel()but oh well, hindsight is 20/20! I'm looking forward toPromise.withResolverto make it to all LTS to simplify that further.
I'm very happy with the state of that feature inside @inquirer/core. If you want to merge this sooner, we could extract while we sidebar the inquirer interface question.
AbortSignal.any() requires node 18.17.0 and 20.3.0.
I don't know a easy way to replace it.
This PR now adds Signal support to the createPromptModule, to inquirer.prompt() and uses signal to handle promise.ui.close().
Did you look into polyfilling AborySignal.any() yet?
Did you look into polyfilling AborySignal.any() yet?
There is AbortSignal polyfills but not any().
Great! Thanks for all the back and forth on this one 🤞🏻