An issue with Node.js' util.inspect function. I use it to colorize Node.js console output and to format objects. All works fine except that util.inspect prints all those \r\n characters too.
The example. Given a file:
// foo.js
console.log("css:\n", util.inspect(css, { depth: 5, colors: true }), '\n');
The output:

How to make util.inspect not to print all those \r\n characters?
Looks like the solution suggested in the docs is to manually remove the new line characters:
util.inspect(css, { depth: 5, colors: true }).replace(/\r?\n/g, '')
According to the current documentation of util.inspect, all you need to do is to set breakLength to Infinity and compact to true.
In your case that would be
console.log("css:\n", util.inspect(css, {
depth: 5,
colors: true,
breakLength: Infinity,
compact: true,
}), '\n');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With