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

doc: simplify recommendations in process.md #42556

Merged
merged 1 commit into from
Apr 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
<!-- source_link=lib/process.js -->

The `process` object provides information about, and control over, the current
Node.js process. While it is available as a global, it is recommended to
explicitly access it via require or import:
Node.js process.
Copy link
Member Author

Choose a reason for hiding this comment

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

My preference here would be to add text explaining why the global should be avoided, but I don't know what that reason is. Also, with this change, there is now no mention of process being available as a global and that is something that should be mentioned.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's mentioned here:

node/doc/api/globals.md

Lines 467 to 477 in 175638b

## `process`
<!-- YAML
added: v0.1.7
-->
<!-- type=global -->
* {Object}
The process object. See the [`process` object][] section.

I don't think we need more, especially if the intent is to promote importing/requiring the core module rather than rely on the global property.


```mjs
import process from 'process';
Expand Down Expand Up @@ -1487,8 +1486,7 @@ The following additional handling is implemented if the warning `type` is
### Avoiding duplicate warnings

As a best practice, warnings should be emitted only once per process. To do
so, it is recommended to place the `emitWarning()` behind a simple boolean
flag as illustrated in the example below:
so, place the `emitWarning()` behind a boolean.

```mjs
import { emitWarning } from 'process';
Expand Down