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

Improve documentation of sync methods #540

Merged
merged 1 commit into from
Mar 9, 2023
Merged

Improve documentation of sync methods #540

merged 1 commit into from
Mar 9, 2023

Conversation

ehmicky
Copy link
Collaborator

@ehmicky ehmicky commented Mar 7, 2023

Just like in core Node.js modules, synchronous methods should mostly be avoided, except in specific situations where they are necessary. This PR improves their documentation based on this.

First, it moves them down in the readme and group them together. This reduces the amount of things to learn for users: they can just focus on the differences on the 4 main invocation methods, and then, as a follow-up, learn that synchronous methods for them exist as well.

Second, their description in both the readme and the type tests were a little out-of-sync. This updates them.

index.d.ts Outdated

@param file - The program/script to execute.
@param arguments - Arguments to pass to `file` on execution.
@returns A result `Object` with `stdout` and `stderr` properties.
@returns A `childProcessResult` object. This is also thrown on error.
Copy link
Contributor

Choose a reason for hiding this comment

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

Wonder if the @throws tag is appropriate here.

Copy link
Collaborator Author

@ehmicky ehmicky Mar 9, 2023

Choose a reason for hiding this comment

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

Good point! Fixed. 👍
I also added @throws to all the main methods, and made their @returns be consistent with each other.

@sindresorhus sindresorhus merged commit 1e23e91 into main Mar 9, 2023
@sindresorhus sindresorhus deleted the doc-sync branch March 9, 2023 02:17
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.

None yet

3 participants