Skip to content

Commit 4111c57

Browse files
UziTechTrott
authored andcommitted
fs: add default options for *stat()
PR-URL: #29114 Fixes: #29113 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 841df6a commit 4111c57

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/fs.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ function readdirSync(path, options) {
796796
return options.withFileTypes ? getDirents(path, result) : result;
797797
}
798798

799-
function fstat(fd, options, callback) {
799+
function fstat(fd, options = { bigint: false }, callback) {
800800
if (typeof options === 'function') {
801801
callback = options;
802802
options = {};
@@ -807,7 +807,7 @@ function fstat(fd, options, callback) {
807807
binding.fstat(fd, options.bigint, req);
808808
}
809809

810-
function lstat(path, options, callback) {
810+
function lstat(path, options = { bigint: false }, callback) {
811811
if (typeof options === 'function') {
812812
callback = options;
813813
options = {};
@@ -819,7 +819,7 @@ function lstat(path, options, callback) {
819819
binding.lstat(pathModule.toNamespacedPath(path), options.bigint, req);
820820
}
821821

822-
function stat(path, options, callback) {
822+
function stat(path, options = { bigint: false }, callback) {
823823
if (typeof options === 'function') {
824824
callback = options;
825825
options = {};

test/parallel/test-fs-stat.js

+11
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,14 @@ fs.stat(__filename, common.mustCall(function(err, s) {
154154
}
155155
);
156156
});
157+
158+
// Should not throw an error
159+
fs.stat(__filename, undefined, common.mustCall(() => {}));
160+
161+
fs.open(__filename, 'r', undefined, common.mustCall((err, fd) => {
162+
// Should not throw an error
163+
fs.fstat(fd, undefined, common.mustCall(() => {}));
164+
}));
165+
166+
// Should not throw an error
167+
fs.lstat(__filename, undefined, common.mustCall(() => {}));

0 commit comments

Comments
 (0)