lib: use emitWarning instead of printDeprecationMessage
The process.emitWarning() API should be used for printing deprecation warning messages rather than directly using the internal/util#printDeprecationMessage PR-URL: https://github.com/nodejs/node/pull/8166 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
This commit is contained in:
parent
bf91035364
commit
15eaba98a1
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const msg = require('internal/util').printDeprecationMessage;
|
|
||||||
|
|
||||||
module.exports = require('internal/linkedlist');
|
module.exports = require('internal/linkedlist');
|
||||||
msg('_linklist module is deprecated. Please use a userland alternative.');
|
process.emitWarning(
|
||||||
|
'_linklist module is deprecated. Please use a userland alternative.',
|
||||||
|
'DeprecationWarning');
|
||||||
|
@ -63,7 +63,10 @@ exports._deprecate = function(fn, msg) {
|
|||||||
|
|
||||||
var warned = false;
|
var warned = false;
|
||||||
function deprecated() {
|
function deprecated() {
|
||||||
warned = exports.printDeprecationMessage(msg, warned, deprecated);
|
if (!warned) {
|
||||||
|
warned = true;
|
||||||
|
process.emitWarning(msg, 'DeprecationWarning', deprecated);
|
||||||
|
}
|
||||||
if (new.target) {
|
if (new.target) {
|
||||||
return Reflect.construct(fn, arguments, new.target);
|
return Reflect.construct(fn, arguments, new.target);
|
||||||
}
|
}
|
||||||
|
@ -196,10 +196,14 @@ Module._findPath = function(request, paths, isMain) {
|
|||||||
if (filename) {
|
if (filename) {
|
||||||
// Warn once if '.' resolved outside the module dir
|
// Warn once if '.' resolved outside the module dir
|
||||||
if (request === '.' && i > 0) {
|
if (request === '.' && i > 0) {
|
||||||
warned = internalUtil.printDeprecationMessage(
|
if (!warned) {
|
||||||
'warning: require(\'.\') resolved outside the package ' +
|
warned = true;
|
||||||
'directory. This functionality is deprecated and will be removed ' +
|
process.emitWarning(
|
||||||
'soon.', warned);
|
'warning: require(\'.\') resolved outside the package ' +
|
||||||
|
'directory. This functionality is deprecated and will be removed ' +
|
||||||
|
'soon.',
|
||||||
|
'DeprecationWarning');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Module._pathCache[cacheKey] = filename;
|
Module._pathCache[cacheKey] = filename;
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const util = require('internal/util');
|
|
||||||
|
|
||||||
// the sys module was renamed to 'util'.
|
// the sys module was renamed to 'util'.
|
||||||
// this shim remains to keep old programs working.
|
// this shim remains to keep old programs working.
|
||||||
// sys is deprecated and shouldn't be used
|
// sys is deprecated and shouldn't be used
|
||||||
|
|
||||||
module.exports = require('util');
|
module.exports = require('util');
|
||||||
util.printDeprecationMessage('sys is deprecated. Use util instead.');
|
process.emitWarning('sys is deprecated. Use util instead.',
|
||||||
|
'DeprecationWarning');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user