aboutsummaryrefslogtreecommitdiff
path: root/doc/api/process.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/api/process.md')
-rw-r--r--doc/api/process.md25
1 files changed, 12 insertions, 13 deletions
diff --git a/doc/api/process.md b/doc/api/process.md
index d2f101419d..92b55b35ee 100644
--- a/doc/api/process.md
+++ b/doc/api/process.md
@@ -283,7 +283,7 @@ command-line option can be used to suppress the default console output but the
The following example illustrates the warning that is printed to `stderr` when
too many listeners have been added to an event
-```
+```txt
$ node
> event.defaultMaxListeners = 1;
> process.on('foo', () => {});
@@ -295,7 +295,7 @@ $ node
In contrast, the following example turns off the default warning output and
adds a custom handler to the `'warning'` event:
-```
+```txt
$ node --no-warnings
> var p = process.on('warning', (warning) => console.warn('Do not do that!'));
> event.defaultMaxListeners = 1;
@@ -467,7 +467,7 @@ process.argv.forEach((val, index) => {
Launching the Node.js process as:
-```
+```sh
$ node process-2.js one two=three four
```
@@ -645,7 +645,7 @@ It is possible to modify this object, but such modifications will not be
reflected outside the Node.js process. In other words, the following example
would not work:
-```
+```sh
$ node -e 'process.env.foo = "bar"' && echo $foo
```
@@ -703,7 +703,7 @@ process.emitWarning('Something happened!');
// Emits: (node: 56338) Warning: Something happened!
```
-```
+```js
// Emit a warning using a string and a name...
process.emitWarning('Something Happened!', 'CustomWarning');
// Emits: (node:56338) CustomWarning: Something Happened!
@@ -713,7 +713,7 @@ In each of the previous examples, an `Error` object is generated internally by
`process.emitWarning()` and passed through to the
[`process.on('warning')`][process_warning] event.
-```
+```js
process.on('warning', (warning) => {
console.warn(warning.name);
console.warn(warning.message);
@@ -725,7 +725,7 @@ If `warning` is passed as an `Error` object, it will be passed through to the
`process.on('warning')` event handler unmodified (and the optional `name`
and `ctor` arguments will be ignored):
-```
+```js
// Emit a warning using an Error object...
const myWarning = new Error('Warning! Something happened!');
myWarning.name = 'CustomWarning';
@@ -756,7 +756,7 @@ 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:
-```
+```js
var warned = false;
function emitMyWarning() {
if (!warned) {
@@ -784,7 +784,7 @@ the same execution environment as the parent.
For example:
-```
+```sh
$ node --harmony script.js --version
```
@@ -810,7 +810,7 @@ that started the Node.js process.
For example:
-```
+```sh
/usr/local/bin/node
```
@@ -1501,7 +1501,7 @@ To check if Node.js is being run in a [TTY][] context, check the `isTTY`
property on `process.stderr`, `process.stdout`, or `process.stdin`.
For instance:
-```
+```sh
$ node -p "Boolean(process.stdin.isTTY)"
true
$ echo "foo" | node -p "Boolean(process.stdin.isTTY)"
@@ -1664,11 +1664,10 @@ cases:
[`process.argv`]: #process_process_argv
[`process.exit()`]: #process_process_exit_code
[`process.kill()`]: #process_process_kill_pid_signal
-[`process.execPath`]: #process_process_execPath
+[`process.execPath`]: #process_process_execpath
[`promise.catch()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch
[`require.main`]: modules.html#modules_accessing_the_main_module
[`setTimeout(fn, 0)`]: timers.html#timers_settimeout_callback_delay_arg
-[child_process `'disconnect'` event]: child_process.html#child_process_event_disconnect
[process_emit_warning]: #process_process_emitwarning_warning_name_ctor
[process_warning]: #process_event_warning
[Signal Events]: #process_signal_events