How to apply a colour when piping stdout from a child process?
Asked Answered
B

0

10

I'm using chalk to colour the output from from my command-line node application. Normally like this:

console.log(chalk.red(error));

However, I need to pipe stdout from a child process, and colour this output too:

var child = childProcess.spawn('foo', args);
child.stdout.pipe(process.stdout); //how to use chalk to colour this?

How do I use chalk to apply a colour when piping stdout in from a child process?

Broek answered 31/3, 2015 at 9:3 Comment(1)
What kind of color? Just color everything a single set of colors? If you need to do selective coloring, you're going to have to write some middleware for it. If you're wanting to have the child process output its colors, that's an entirely different problem unrelated to chalk.Venose

© 2022 - 2024 — McMap. All rights reserved.