mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
We (correctly) allow different streams to be specified for `stdout` and `stderr`, so we should also allow different inspect options for these streams. PR-URL: https://github.com/nodejs/node/pull/60082 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jordan Harband <ljharb@gmail.com>
24 lines
597 B
JavaScript
24 lines
597 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const { Console } = require('console');
|
|
const { PassThrough } = require('stream');
|
|
const { strict: assert } = require('assert');
|
|
|
|
const stdout = new PassThrough().setEncoding('utf8');
|
|
const stderr = new PassThrough().setEncoding('utf8');
|
|
|
|
const console = new Console({
|
|
stdout,
|
|
stderr,
|
|
inspectOptions: new Map([
|
|
[stdout, { colors: true }],
|
|
[stderr, { colors: false }],
|
|
]),
|
|
});
|
|
|
|
console.log('Hello', 42);
|
|
console.warn('Hello', 42);
|
|
|
|
assert.strictEqual(stdout.read(), 'Hello \x1B[33m42\x1B[39m\n');
|
|
assert.strictEqual(stderr.read(), 'Hello 42\n');
|