diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 8aa25ee70d07b5..f38e225ef7c593 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -855,8 +855,12 @@ const validateRmOptionsSync = hideStackFrames((path, options, expectDir) => { return options; }); -let recursiveRmdirWarned = process.noDeprecation; +let recursiveRmdirWarned; function emitRecursiveRmdirWarning() { + if (recursiveRmdirWarned === undefined) { + // TODO(joyeecheung): use getOptionValue('--no-deprecation') instead. + recursiveRmdirWarned = process.noDeprecation; + } if (!recursiveRmdirWarned) { process.emitWarning( 'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' + diff --git a/lib/internal/util.js b/lib/internal/util.js index b32c0e8472b320..603f8164a14405 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -142,10 +142,6 @@ function pendingDeprecate(fn, msg, code) { // Returns a modified function which warns once by default. // If --no-deprecation is set, then it is a no-op. function deprecate(fn, msg, code, useEmitSync) { - if (process.noDeprecation === true) { - return fn; - } - // Lazy-load to avoid a circular dependency. if (validateString === undefined) ({ validateString } = require('internal/validators')); @@ -158,7 +154,10 @@ function deprecate(fn, msg, code, useEmitSync) { ); function deprecated(...args) { - emitDeprecationWarning(); + // TODO(joyeecheung): use getOptionValue('--no-deprecation') instead. + if (!process.noDeprecation) { + emitDeprecationWarning(); + } if (new.target) { return ReflectConstruct(fn, args, new.target); }