Browse Source

internal/util: remove printDeprecationWarning

Removes the internal/util printDeprecationWarning method

PR-URL: https://github.com/nodejs/node/pull/8166
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
v7.x
James M Snell 9 years ago
parent
commit
7b73f55902
  1. 10
      lib/internal/util.js
  2. 7
      test/parallel/test-process-no-deprecation.js

10
lib/internal/util.js

@ -19,16 +19,6 @@ exports.deprecate = function(fn, msg) {
return exports._deprecate(fn, msg); return exports._deprecate(fn, msg);
}; };
// All the internal deprecations have to use this function only, as this will
// prepend the prefix to the actual message.
exports.printDeprecationMessage = function(msg, warned, ctor) {
if (warned || process.noDeprecation)
return true;
process.emitWarning(msg, 'DeprecationWarning',
ctor || exports.printDeprecationMessage);
return true;
};
exports.error = function(msg) { exports.error = function(msg) {
const fmt = `${prefix}${msg}`; const fmt = `${prefix}${msg}`;
if (arguments.length > 1) { if (arguments.length > 1) {

7
test/parallel/test-process-no-deprecation.js

@ -1,5 +1,5 @@
'use strict'; 'use strict';
// Flags: --expose_internals --no-warnings // Flags: --no-warnings
// The --no-warnings flag only supresses writing the warning to stderr, not the // The --no-warnings flag only supresses writing the warning to stderr, not the
// emission of the corresponding event. This test file can be run without it. // emission of the corresponding event. This test file can be run without it.
@ -15,8 +15,7 @@ function listener() {
process.addListener('warning', listener); process.addListener('warning', listener);
const internalUtil = require('internal/util'); process.emitWarning('Something is deprecated.', 'DeprecationWarning');
internalUtil.printDeprecationMessage('Something is deprecated.');
// The warning would be emitted in the next tick, so continue after that. // The warning would be emitted in the next tick, so continue after that.
process.nextTick(common.mustCall(() => { process.nextTick(common.mustCall(() => {
@ -29,5 +28,5 @@ process.nextTick(common.mustCall(() => {
assert.strictEqual(warning.message, 'Something else is deprecated.'); assert.strictEqual(warning.message, 'Something else is deprecated.');
})); }));
internalUtil.printDeprecationMessage('Something else is deprecated.'); process.emitWarning('Something else is deprecated.', 'DeprecationWarning');
})); }));

Loading…
Cancel
Save