Skip to content

Commit 178caa5

Browse files
UziTechtargos
authored andcommitted
fs: add default options for *stat()
PR-URL: #29114Fixes: #29113 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 62a0e91 commit 178caa5

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

‎lib/fs.js‎

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

799-
functionfstat(fd,options,callback){
799+
functionfstat(fd,options={bigint: false},callback){
800800
if(typeofoptions==='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-
functionlstat(path,options,callback){
810+
functionlstat(path,options={bigint: false},callback){
811811
if(typeofoptions==='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-
functionstat(path,options,callback){
822+
functionstat(path,options={bigint: false},callback){
823823
if(typeofoptions==='function'){
824824
callback=options;
825825
options={};

‎test/parallel/test-fs-stat.js‎

Lines changed: 11 additions & 0 deletions
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)