Question

You can give it a ride yourself, below is the code in copy-able format.

Here's chalked.js

var chalk = require('chalk');

console.log('Immediately!');

setTimeout(function () {
    console.log(chalk.red('Right after!'));
}, 400);

setTimeout(function () {
    process.stdout.write('And ' + chalk.magenta('...'));

    setTimeout(function () {
        console.log(chalk.underline('it\'s gone!'));
    }, 2000);
}, 5000);

Then there's piper.js

process.stdin.pipe(process.stdout);

enter image description here

How can I preserve color formatting through these pipes?

Was it helpful?

Solution

So far as I can tell, Chalk disables colour support when not writing to a TTY. It looks like you need to supply the --color arg.

You can also set the environment variable FORCE_COLOR=1 to force colors for anything that uses Chalk.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top