Skip to content

Commit f29451d

Browse files
himself65danielleadams
authored andcommitted
fs: simplify realpathSync
PR-URL: #35413 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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
const emptyObj = ObjectCreate(null);
16001600
function realpathSync(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 (typeof p !== '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
const ctx = { path: base };
16381635
binding.lstat(pathModule.toNamespacedPath(base), false, undefined, ctx);
16391636
handleErrorFromBinding(ctx);
@@ -1831,7 +1828,7 @@ function realpath(p, options, callback) {
18311828
const ino = stats.ino.toString(32);
18321829
id = `${dev}:${ino}`;
18331830
if (seenLinks[id]) {
1834-
return gotTarget(null, seenLinks[id], base);
1831+
return gotTarget(null, seenLinks[id]);
18351832
}
18361833
}
18371834
fs.stat(base, (err) => {
@@ -1844,7 +1841,7 @@ function realpath(p, options, callback) {
18441841
});
18451842
}
18461843

1847-
function gotTarget(err, target, base) {
1844+
function gotTarget(err, target) {
18481845
if (err) return callback(err);
18491846

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

0 commit comments

Comments
 (0)