Skip to content

Commit 0b22b1d

Browse files
committed
(fix #248) follow directory links in getNode
When called from stat, getNode should follow directory links to ensure that the correct node is returned. Otherwise, node.files[name] will be undefined, causing a TypeError.
1 parent 8f7d96d commit 0b22b1d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/filesystem.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,12 @@ export class Filesystem {
190190
return files;
191191
}
192192

193-
getNode(p: string) {
193+
getNode(p: string, followLinks: boolean = true): FilesystemEntry {
194194
const node = this.searchNodeFromDirectory(path.dirname(p));
195195
const name = path.basename(p);
196+
if ('link' in node && followLinks) {
197+
return this.getNode(path.join(node.link, name));
198+
}
196199
if (name) {
197200
return (node as FilesystemDirectoryEntry).files[name];
198201
} else {
@@ -201,7 +204,7 @@ export class Filesystem {
201204
}
202205

203206
getFile(p: string, followLinks: boolean = true): FilesystemEntry {
204-
const info = this.getNode(p);
207+
const info = this.getNode(p, followLinks);
205208

206209
if (!info) {
207210
throw new Error(`"${p}" was not found in this archive`);

0 commit comments

Comments
 (0)