Skip to content
Permalink
Browse files

fs: add default options for *stat()

PR-URL: #29114
Fixes: #29113
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information...
UziTech authored and targos committed Aug 14, 2019
1 parent 62a0e91 commit 178caa56ae17aea78e68d2cf76e1e489b536420f
Showing with 14 additions and 3 deletions.
  1. +3 −3 lib/fs.js
  2. +11 −0 test/parallel/test-fs-stat.js
@@ -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 = {};
@@ -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 = {};
@@ -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 = {};
@@ -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 178caa5

Please sign in to comment.
You can’t perform that action at this time.