Skip to content

Commit

Permalink
fs: add default options for *stat()
Browse files Browse the repository at this point in the history
PR-URL: #29114
Fixes: #29113
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
UziTech authored and Trott committed Aug 16, 2019
1 parent 841df6a commit 4111c57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ function readdirSync(path, options) {
return options.withFileTypes ? getDirents(path, result) : result;
}

function fstat(fd, options, callback) {
function fstat(fd, options = { bigint: false }, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
Expand All @@ -807,7 +807,7 @@ function fstat(fd, options, callback) {
binding.fstat(fd, options.bigint, req);
}

function lstat(path, options, callback) {
function lstat(path, options = { bigint: false }, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
Expand All @@ -819,7 +819,7 @@ function lstat(path, options, callback) {
binding.lstat(pathModule.toNamespacedPath(path), options.bigint, req);
}

function stat(path, options, callback) {
function stat(path, options = { bigint: false }, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
Expand Down
11 changes: 11 additions & 0 deletions test/parallel/test-fs-stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,14 @@ fs.stat(__filename, common.mustCall(function(err, s) {
}
);
});

// Should not throw an error
fs.stat(__filename, undefined, common.mustCall(() => {}));

fs.open(__filename, 'r', undefined, common.mustCall((err, fd) => {
// Should not throw an error
fs.fstat(fd, undefined, common.mustCall(() => {}));
}));

// Should not throw an error
fs.lstat(__filename, undefined, common.mustCall(() => {}));

0 comments on commit 4111c57

Please sign in to comment.