Skip to content

Commit 8bb60e3

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. PR-URL: #5590 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 3c84752 commit 8bb60e3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/fs.js

+2-2
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)