Skip to content

Commit

Permalink
fs: simplify validateRmOptions() error handling
Browse files Browse the repository at this point in the history
PR-URL: #35567
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
  • Loading branch information
cjihrig authored and MylesBorins committed Oct 14, 2020
1 parent 8e3b11a commit 1fadcf2
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 @@ -684,17 +684,13 @@ const validateRmOptions = hideStackFrames((path, options, callback) => {
);

lazyLoadFs().stat(path, (err, stats) => {
if (err && err.code === 'ENOENT') {
if (options.force) {
if (err) {
if (options.force && err.code === 'ENOENT') {
return callback(null, options);
}
return callback(err, options);
}

if (err) {
return callback(err);
}

if (stats.isDirectory() && !options.recursive) {
return callback(new ERR_FS_EISDIR({
code: 'EISDIR',
Expand Down

0 comments on commit 1fadcf2

Please sign in to comment.