Skip to content

Commit f29451d

Browse files
himself65danielleadams
authored andcommitted
fs: simplify realpathSync
PR-URL: #35413 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 3f95440 commit f29451d

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

‎lib/fs.js‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,10 +1598,7 @@ if (isWindows){
15981598

15991599
constemptyObj=ObjectCreate(null);
16001600
functionrealpathSync(p,options){
1601-
if(!options)
1602-
options=emptyObj;
1603-
else
1604-
options=getOptions(options,emptyObj);
1601+
options=getOptions(options,emptyObj);
16051602
p=toPathIfFileURL(p);
16061603
if(typeofp!=='string'){
16071604
p+='';
@@ -1633,7 +1630,7 @@ function realpathSync(p, options){
16331630
pos=current.length;
16341631

16351632
// On windows, check that the root exists. On unix there is no need.
1636-
if(isWindows&&!knownHard[base]){
1633+
if(isWindows){
16371634
constctx={path: base};
16381635
binding.lstat(pathModule.toNamespacedPath(base),false,undefined,ctx);
16391636
handleErrorFromBinding(ctx);
@@ -1831,7 +1828,7 @@ function realpath(p, options, callback){
18311828
constino=stats.ino.toString(32);
18321829
id=`${dev}:${ino}`;
18331830
if(seenLinks[id]){
1834-
returngotTarget(null,seenLinks[id],base);
1831+
returngotTarget(null,seenLinks[id]);
18351832
}
18361833
}
18371834
fs.stat(base,(err)=>{
@@ -1844,7 +1841,7 @@ function realpath(p, options, callback){
18441841
});
18451842
}
18461843

1847-
functiongotTarget(err,target,base){
1844+
functiongotTarget(err,target){
18481845
if(err)returncallback(err);
18491846

18501847
gotResolvedLink(pathModule.resolve(previous,target));

0 commit comments

Comments
(0)