Skip to content

Request: Add small note in README for using debug in child processes #811

Description

@aaarichter

Hi,

Due to the process.isTTY check, it can happen that colors are not shown in child process when stderr is piped.

chalk/supports-color#94 (comment) gave an easy solution to fix this problem.
Request: It would be nice if the readme would mention this workaround.

example code from my project, where a worker with the actual server is forked and passed to node repl. Without setting DEBUG_COLORS: 1, there won't be any colors 😿 .

worker = fork(WORKER_WRAP_PATH, [workerPath], {
  stdio: [
    /* stdin: */ 0,
    /* stdout: */ 'pipe',
    /* stderr: */ 'pipe',
    'ipc',
  ],
  env: Object.assign({}, process.env, {
    DEBUG_COLORS: 1 // without this settings, colors won't be shown
  }),
});

worker.stderr.pipe(process.stderr, { end: false });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help-wantedThis issue has an actionable itempr-welcomeThis issue has an approved change; a pull request would be appreciated

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions