Skip to content

Commit

Permalink
fs: throw rm() validation errors
Browse files Browse the repository at this point in the history
This commit updates validateRmOptions() to throw on input
validation failures. This is consistent with how Node handles
validation in most places across the codebase.

PR-URL: #35602
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
  • Loading branch information
cjihrig authored and nodejs-github-bot committed Oct 13, 2020
1 parent ce4ac15 commit adf8f3d
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,12 +673,8 @@ const defaultRmdirOptions = {
};

const validateRmOptions = hideStackFrames((path, options, callback) => {
try {
options = validateRmdirOptions(options, defaultRmOptions);
validateBoolean(options.force, 'options.force');
} catch (err) {
return callback(err);
}
options = validateRmdirOptions(options, defaultRmOptions);
validateBoolean(options.force, 'options.force');

lazyLoadFs().stat(path, (err, stats) => {
if (err) {
Expand Down

0 comments on commit adf8f3d

Please sign in to comment.