Skip to content

Commit

Permalink
fixup! fs: introduce dirent.parentPath
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Dec 4, 2023
1 parent 181eca5 commit 3db63d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/internal/fs/dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class Dir {
path,
result[i],
result[i + 1],
true, // Quirk to not introduce a breaking change.
),
);
}
Expand Down
10 changes: 7 additions & 3 deletions lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function join(path, name) {
}

if (typeof path === 'string' && typeof name === 'string') {
return pathModule.basename(path) === name ? path : pathModule.join(path, name);
return pathModule.join(path, name);
}

if (isUint8Array(path) && isUint8Array(name)) {
Expand Down Expand Up @@ -313,9 +313,13 @@ function getDirent(path, name, type, callback) {
} else if (type === UV_DIRENT_UNKNOWN) {
const filepath = join(path, name);
const stats = lazyLoadFs().lstatSync(filepath);
return new DirentFromStats(name, stats, path, filepath);
} else {
// callback === true: Quirk to not introduce a breaking change.
return new DirentFromStats(name, stats, path, callback === true ? filepath : path);
} else if (callback === true) {
// callback === true: Quirk to not introduce a breaking change.
return new Dirent(name, type, path);
} else {
return new Dirent(name, type, path, path);
}
}

Expand Down

0 comments on commit 3db63d2

Please sign in to comment.