diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 8c9a353bf8664b..6d47e68aa32cf9 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -859,8 +859,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 93a7422d3f4fe1..0b261a82432609 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); }