util: pass on additional error() args
This fixes breakage introduced in 94b9948d63 when writing the max EventEmitter listeners warning to stderr. PR-URL: https://github.com/nodejs/node/pull/4279 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
852313af65
commit
0b43c08f44
@ -18,7 +18,16 @@ exports.printDeprecationMessage = function(msg, warned) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.error = function(msg) {
|
exports.error = function(msg) {
|
||||||
console.error(`${prefix}${msg}`);
|
const fmt = `${prefix}${msg}`;
|
||||||
|
if (arguments.length > 1) {
|
||||||
|
const args = new Array(arguments.length);
|
||||||
|
args[0] = fmt;
|
||||||
|
for (let i = 1; i < arguments.length; ++i)
|
||||||
|
args[i] = arguments[i];
|
||||||
|
console.error.apply(console, args);
|
||||||
|
} else {
|
||||||
|
console.error(fmt);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.trace = function(msg) {
|
exports.trace = function(msg) {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const internalUtil = require('internal/util');
|
const internalUtil = require('internal/util');
|
||||||
|
const spawnSync = require('child_process').spawnSync;
|
||||||
|
|
||||||
function getHiddenValue(obj, name) {
|
function getHiddenValue(obj, name) {
|
||||||
return function() {
|
return function() {
|
||||||
@ -30,3 +31,12 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert(/bad_syntax\.js:1/.test(arrowMessage));
|
assert(/bad_syntax\.js:1/.test(arrowMessage));
|
||||||
|
|
||||||
|
const args = [
|
||||||
|
'--expose-internals',
|
||||||
|
'-e',
|
||||||
|
"require('internal/util').error('foo %d', 5)"
|
||||||
|
];
|
||||||
|
const result = spawnSync(process.argv[0], args, { encoding: 'utf8' });
|
||||||
|
assert.strictEqual(result.stderr.indexOf('%'), -1);
|
||||||
|
assert(/foo 5/.test(result.stderr));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user