Skip to content

Commit 8e3b11a

Browse files
cjihrigMylesBorins
authored andcommitted
fs: use errno constant with ERR_FS_EISDIR
This commit updates rm() to use the EISDIR constant with ERR_FS_EISDIR instead of hard coding -21. PR-URL: #35563 Reviewed-By: Ben Coe <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent b074717 commit 8e3b11a

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed

lib/internal/fs/utils.js

+43-36
Original file line numberDiff line numberDiff line change
@@ -46,40 +46,47 @@ const kStats = Symbol('stats');
4646
const assert = require('internal/assert');
4747

4848
const {
49-
F_OK = 0,
50-
W_OK = 0,
51-
R_OK = 0,
52-
X_OK = 0,
53-
COPYFILE_EXCL,
54-
COPYFILE_FICLONE,
55-
COPYFILE_FICLONE_FORCE,
56-
O_APPEND,
57-
O_CREAT,
58-
O_EXCL,
59-
O_RDONLY,
60-
O_RDWR,
61-
O_SYNC,
62-
O_TRUNC,
63-
O_WRONLY,
64-
S_IFBLK,
65-
S_IFCHR,
66-
S_IFDIR,
67-
S_IFIFO,
68-
S_IFLNK,
69-
S_IFMT,
70-
S_IFREG,
71-
S_IFSOCK,
72-
UV_FS_SYMLINK_DIR,
73-
UV_FS_SYMLINK_JUNCTION,
74-
UV_DIRENT_UNKNOWN,
75-
UV_DIRENT_FILE,
76-
UV_DIRENT_DIR,
77-
UV_DIRENT_LINK,
78-
UV_DIRENT_FIFO,
79-
UV_DIRENT_SOCKET,
80-
UV_DIRENT_CHAR,
81-
UV_DIRENT_BLOCK
82-
} = internalBinding('constants').fs;
49+
fs: {
50+
F_OK = 0,
51+
W_OK = 0,
52+
R_OK = 0,
53+
X_OK = 0,
54+
COPYFILE_EXCL,
55+
COPYFILE_FICLONE,
56+
COPYFILE_FICLONE_FORCE,
57+
O_APPEND,
58+
O_CREAT,
59+
O_EXCL,
60+
O_RDONLY,
61+
O_RDWR,
62+
O_SYNC,
63+
O_TRUNC,
64+
O_WRONLY,
65+
S_IFBLK,
66+
S_IFCHR,
67+
S_IFDIR,
68+
S_IFIFO,
69+
S_IFLNK,
70+
S_IFMT,
71+
S_IFREG,
72+
S_IFSOCK,
73+
UV_FS_SYMLINK_DIR,
74+
UV_FS_SYMLINK_JUNCTION,
75+
UV_DIRENT_UNKNOWN,
76+
UV_DIRENT_FILE,
77+
UV_DIRENT_DIR,
78+
UV_DIRENT_LINK,
79+
UV_DIRENT_FIFO,
80+
UV_DIRENT_SOCKET,
81+
UV_DIRENT_CHAR,
82+
UV_DIRENT_BLOCK
83+
},
84+
os: {
85+
errno: {
86+
EISDIR
87+
}
88+
}
89+
} = internalBinding('constants');
8390

8491
// The access modes can be any of F_OK, R_OK, W_OK or X_OK. Some might not be
8592
// available on specific systems. They can be used in combination as well
@@ -694,7 +701,7 @@ const validateRmOptions = hideStackFrames((path, options, callback) => {
694701
message: 'is a directory',
695702
path,
696703
syscall: 'rm',
697-
errno: -21
704+
errno: EISDIR
698705
}));
699706
}
700707
return callback(null, options);
@@ -716,7 +723,7 @@ const validateRmOptionsSync = hideStackFrames((path, options) => {
716723
message: 'is a directory',
717724
path,
718725
syscall: 'rm',
719-
errno: -21
726+
errno: EISDIR
720727
});
721728
}
722729
} catch (err) {

0 commit comments

Comments
 (0)