Skip to content

Commit a255da4

Browse files
committed
fs: improve error message for invalid flag
Flags on fs.open and others can be passed as strings or int. Previously, if passing anything other than string or int, the error message would only say that flags must be an int.
1 parent 3c84752 commit a255da4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/fs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ fs.readFileSync = function(path, options) {
536536

537537
// Used by binding.open and friends
538538
function stringToFlags(flag) {
539-
// Only mess with strings
540-
if (typeof flag !== 'string') {
539+
// Return early if it's a number
540+
if (typeof flag === 'number') {
541541
return flag;
542542
}
543543

0 commit comments

Comments
 (0)