fs: throw rm() validation errors

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: https://github.com/nodejs/node/pull/35602
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
This commit is contained in:
cjihrig authored and Myles Borins committed 2020-10-14 16:21:27 -04:00
1 parent cd0b1365ae
commit 939f8e8bfa
1 file changed
+2 -6
+2 -6
View File
@@ -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) {