Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recursiveRmdirWarned = recursiveRmdirWarned || process.noDeprecation;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would make the code harder to understand when we are lazily initializing a boolean.

}
if (!recursiveRmdirWarned) {
process.emitWarning(
'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' +
Expand Down
9 changes: 4 additions & 5 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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);
}
Expand Down