Skip to content

Commit 1fadcf2

Browse files
cjihrigMylesBorins
authored andcommittedOct 14, 2020
fs: simplify validateRmOptions() error handling
PR-URL: #35567 Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Anto Aravinth <[email protected]>
1 parent 8e3b11a commit 1fadcf2

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed
 

‎lib/internal/fs/utils.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -684,17 +684,13 @@ const validateRmOptions = hideStackFrames((path, options, callback) => {
684684
);
685685

686686
lazyLoadFs().stat(path, (err, stats) => {
687-
if (err && err.code === 'ENOENT') {
688-
if (options.force) {
687+
if (err) {
688+
if (options.force && err.code === 'ENOENT') {
689689
return callback(null, options);
690690
}
691691
return callback(err, options);
692692
}
693693

694-
if (err) {
695-
return callback(err);
696-
}
697-
698694
if (stats.isDirectory() && !options.recursive) {
699695
return callback(new ERR_FS_EISDIR({
700696
code: 'EISDIR',

0 commit comments

Comments
 (0)