Skip to content

Commit 9082cc5

Browse files
joyeecheungrichardlau
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 <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
1 parent d90594a commit 9082cc5

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/internal/fs/utils.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -859,8 +859,12 @@ const validateRmOptionsSync = hideStackFrames((path, options, expectDir) => {
859859
return options;
860860
});
861861

862-
let recursiveRmdirWarned = process.noDeprecation;
862+
let recursiveRmdirWarned;
863863
function emitRecursiveRmdirWarning() {
864+
if (recursiveRmdirWarned === undefined) {
865+
// TODO(joyeecheung): use getOptionValue('--no-deprecation') instead.
866+
recursiveRmdirWarned = process.noDeprecation;
867+
}
864868
if (!recursiveRmdirWarned) {
865869
process.emitWarning(
866870
'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' +

lib/internal/util.js

+4-5
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)