util: add internal function _deprecationWarning()
This commit is contained in:
parent
d29be0dfa2
commit
97900776bb
@ -37,12 +37,8 @@ exports.platform = function() {
|
|||||||
return process.platform;
|
return process.platform;
|
||||||
};
|
};
|
||||||
|
|
||||||
var warnNetworkInterfaces = true;
|
|
||||||
exports.getNetworkInterfaces = function() {
|
exports.getNetworkInterfaces = function() {
|
||||||
if (warnNetworkInterfaces) {
|
require('util')._deprecationWarning('os',
|
||||||
console.error("os.getNetworkInterfaces() is deprecated - use os.networkInterfaces()");
|
'os.getNetworkInterfaces() is deprecated - use os.networkInterfaces()');
|
||||||
console.trace();
|
|
||||||
warnNetworkInterfaces = false;
|
|
||||||
}
|
|
||||||
return exports.networkInterfaces();
|
return exports.networkInterfaces();
|
||||||
};
|
};
|
||||||
|
11
lib/sys.js
11
lib/sys.js
@ -21,15 +21,8 @@
|
|||||||
|
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
||||||
var sysWarning;
|
util._deprecationWarning('sys',
|
||||||
if (!sysWarning) {
|
'The "sys" module is now called "util". It should have a similar interface.');
|
||||||
sysWarning = 'The "sys" module is now called "util". ' +
|
|
||||||
'It should have a similar interface.';
|
|
||||||
if (process.env.NODE_DEBUG && process.env.NODE_DEBUG.indexOf('sys') != -1)
|
|
||||||
console.trace(sysWarning);
|
|
||||||
else
|
|
||||||
console.error(sysWarning);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.print = util.print;
|
exports.print = util.print;
|
||||||
exports.puts = util.puts;
|
exports.puts = util.puts;
|
||||||
|
16
lib/util.js
16
lib/util.js
@ -518,3 +518,19 @@ exports.inherits = function(ctor, superCtor) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var deprecationWarnings;
|
||||||
|
|
||||||
|
exports._deprecationWarning = function(moduleId, message) {
|
||||||
|
if (!deprecationWarnings)
|
||||||
|
deprecationWarnings = {};
|
||||||
|
else if (message in deprecationWarnings)
|
||||||
|
return;
|
||||||
|
|
||||||
|
deprecationWarnings[message] = true;
|
||||||
|
|
||||||
|
if ((new RegExp('\\b' + moduleId + '\\b')).test(process.env.NODE_DEBUG))
|
||||||
|
console.trace(message);
|
||||||
|
else
|
||||||
|
console.error(message);
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user