util: adhere to `noDeprecation` set at runtime · nodejs/node@1d6c17e · GitHub
Skip to content

Commit 1d6c17e

Browse files
addaleaxevanlucas
authored andcommitted
util: adhere to noDeprecation set at runtime
Until now, the docs stated that `process.noDeprecation` could be set at runtime, but before any modules were loaded. That was not true, because `lib/internal/util.js` was loaded during the process startup process, so setting the flag at runtime was pointless. Minimal test case: process.noDeprecation = true; process.EventEmitter; This patch moves checking `process.noDeprecation` to the place where it was actually used. PR-URL: #6683 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 3af9382 commit 1d6c17e

3 files changed

Lines changed: 37 additions & 5 deletions

File tree

doc/api/util.md

Lines changed: 3 additions & 3 deletions

lib/internal/util.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const binding = process.binding('util');
44
const prefix = `(${process.release.name}:${process.pid}) `;
5-
const noDeprecation = process.noDeprecation;
65

76
exports.getHiddenValue = binding.getHiddenValue;
87
exports.setHiddenValue = binding.setHiddenValue;
@@ -16,7 +15,7 @@ exports.deprecate = function(fn, msg) {
1615
// All the internal deprecations have to use this function only, as this will
1716
// prepend the prefix to the actual message.
1817
exports.printDeprecationMessage = function(msg, warned, ctor) {
19-
if (warned || noDeprecation)
18+
if (warned || process.noDeprecation)
2019
return true;
2120
process.emitWarning(msg, 'DeprecationWarning',
2221
ctor || exports.printDeprecationMessage);
Lines changed: 33 additions & 0 deletions

0 commit comments

Comments
 (0)