mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
fs: simplify validateRmOptions() error handling
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user