-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
Improve ora.promise()
#181
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
751d71e
changed ora.promise
SrBrahma 14f3014
updated README
SrBrahma b49b6d0
updated README
SrBrahma 519fa17
Did some of the PR requests
SrBrahma e6834a0
Fixed test
SrBrahma 7983de6
Added missing PromiseOptions type
SrBrahma 57a3646
Fixed comments, renamed arg, reordered union type
SrBrahma 68933e8
Changed README
SrBrahma 0089cff
.catch() to try/catch
SrBrahma 0ff1318
Merge pull request #1 from SrBrahma/master
SrBrahma 4e82c94
Spaces to tabs
SrBrahma File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,11 +226,28 @@ Change the spinner indent. | |
### ora.promise(action, text) | ||
### ora.promise(action, options) | ||
|
||
Starts a spinner for a promise. The spinner is stopped with `.succeed()` if the promise fulfills or with `.fail()` if it rejects. Returns the spinner instance. | ||
Starts a spinner for a function or a promise. The spinner is stopped with `.succeed()` if the promise fulfills or with `.fail()` if it rejects. Returns the promise. | ||
|
||
#### action | ||
|
||
Type: `Promise` | ||
Type: `Promise | ((spinner: ora.Ora) => Promise)` | ||
|
||
#### options | ||
|
||
Type: `object` | ||
|
||
All of the [options](#options) plus the following: | ||
|
||
##### successText | ||
Type: `string | ((result: T) => string)` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the functions, I used this as pattern: https://github.com/sindresorhus/got/blob/main/documentation/5-https.md#checkserveridentity. Please, change it further if wanted to fit your README styling. |
||
|
||
The new text of the spinner when the promise is resolved. If undefined, will keep the initial text. | ||
|
||
##### failText | ||
Type: `string | ((error: Error) => string)` | ||
|
||
The new text of the spinner when the promise is rejected. If undefined, will keep the initial text. | ||
|
||
|
||
## FAQ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still messy formatting. Please look over the whole diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why this is happening at all. In my VSCode the indentation is right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't have EditorConfig extension installed here, I was using 2 spaces instead of tab (size 2). The code was looking the same in VSCode, but looks like the diff in GitHub renders tabs as 8 spaces, that's why it was visually strange.
I activated the whitespace rendering, and that's what was happening:
I found out that you are the XO dev. Maybe would be a good idea to have a pre-commit/GitHub action to lint this. Or even, to throw a warn/error on test if spaces were found instead of tabs. In eslint, this is doable.
I hope everything is fixed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for your information, there is a cool eslint plugin for JSDoc: https://github.com/gajus/eslint-plugin-jsdoc
I will soon add it to my personal eslint-config, as I also have my personal taste for JSDoc comments. Maybe you could implement a similar thing for XO to avoid those issues among all your repos, in PRs like mine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's already a thing. Ora just didn't have the latest XO version.
However, you are still expected to look over your own PR diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to add it at some point, but it's some work to evaluate all the rules, and I haven't had the time to do that yet: xojs/xo#378