Skip to content

Commit 70fc7de

Browse files
joyeecheungmarco-ippolito
authored andcommitted
lib: do not access process.noDeprecation at build time
Delay access at run time otherwise the value is captured at build time and always false. PR-URL: #51447 Reviewed-By: Jithil P Ponnan <jithil@outlook.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent a60b3ad commit 70fc7de

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/internal/fs/utils.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,12 @@ const validateRmOptionsSync = hideStackFrames((path, options, expectDir) => {
855855
return options;
856856
});
857857

858-
let recursiveRmdirWarned = process.noDeprecation;
858+
let recursiveRmdirWarned;
859859
function emitRecursiveRmdirWarning() {
860+
if (recursiveRmdirWarned === undefined) {
861+
// TODO(joyeecheung): use getOptionValue('--no-deprecation') instead.
862+
recursiveRmdirWarned = process.noDeprecation;
863+
}
860864
if (!recursiveRmdirWarned) {
861865
process.emitWarning(
862866
'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' +

lib/internal/util.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ function pendingDeprecate(fn, msg, code) {
142142
// Returns a modified function which warns once by default.
143143
// If --no-deprecation is set, then it is a no-op.
144144
function deprecate(fn, msg, code, useEmitSync) {
145-
if (process.noDeprecation === true) {
146-
return fn;
147-
}
148-
149145
// Lazy-load to avoid a circular dependency.
150146
if (validateString === undefined)
151147
({ validateString } = require('internal/validators'));
@@ -158,7 +154,10 @@ function deprecate(fn, msg, code, useEmitSync) {
158154
);
159155

160156
function deprecated(...args) {
161-
emitDeprecationWarning();
157+
// TODO(joyeecheung): use getOptionValue('--no-deprecation') instead.
158+
if (!process.noDeprecation) {
159+
emitDeprecationWarning();
160+
}
162161
if (new.target) {
163162
return ReflectConstruct(fn, args, new.target);
164163
}

0 commit comments

Comments
 (0)