You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
adds README section regarding usage in child procs (#850)
* adds README section regarding usage in child procs
code example and original request copied from @aaarichter
should close#811
* Update README.md
Co-authored-by: Qix <Qix-@users.noreply.github.com>
Co-authored-by: Qix <Qix-@users.noreply.github.com>
Copy file name to clipboardExpand all lines: README.md
+21
Original file line number
Diff line number
Diff line change
@@ -351,6 +351,27 @@ if (debug.enabled) {
351
351
You can also manually toggle this property to force the debug instance to be
352
352
enabled or disabled.
353
353
354
+
## Usage in child processes
355
+
356
+
Due to the way `debug` detects if the output is a TTY or not, colors are not shown in child processes when `stderr` is piped. A solution is to pass the `DEBUG_COLORS=1` environment variable to the child process.
357
+
For example:
358
+
359
+
```javascript
360
+
worker =fork(WORKER_WRAP_PATH, [workerPath], {
361
+
stdio: [
362
+
/* stdin: */0,
363
+
/* stdout: */'pipe',
364
+
/* stderr: */'pipe',
365
+
'ipc',
366
+
],
367
+
env:Object.assign({}, process.env, {
368
+
DEBUG_COLORS:1// without this settings, colors won't be shown
0 commit comments