Skip to content

Commit 275153d

Browse files
cjihrignodejs-github-bot
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 71a48c3 commit 275153d

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed

lib/internal/fs/utils.js

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -44,40 +44,47 @@ const kStats = Symbol('stats');
4444
const assert = require('internal/assert');
4545

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

8289
// The access modes can be any of F_OK, R_OK, W_OK or X_OK. Some might not be
8390
// 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)