Closed SrBrahma closed 3 years ago
The pull request needs a proper descriptive title.
Please always run npm test
locally before pushing changes.
Please always run
npm test
locally before pushing changes.
~I did and fixed my own errors, but there were other errors not related to my changes~
I have no idea on how to fix this npm test issue:
I found out why the test error was happening. The new promise() was calling the promise that always rejects. I thought the promise was being rejected before entering the promise() call. Also, the PromiseOptions type definition was missing, looks like I only had added it to the README.
Thanks :)
Implemented https://github.com/sindresorhus/ora/issues/169#issuecomment-873269524
Improves ora.promise: 1) The action can now be a function. It will automatically be executed. The corresponding spinner will be used as argument to that function. 2) It will now return a promise, that resolves when ora.promise given promise/function is resolved, so the user can
await ora.promise(..)
. 3) Added successText and failText, that will be used in the spinner.succeed()/spinner.fail(). They can be either a string or a function. Being a function, successText will receive as argument the return of the action resolve, and failText will receive the action reject content.Fixes #169