Skip to content

Commit

Permalink
fix: fix handle paths in FSA entries iterator (#1019)
Browse files Browse the repository at this point in the history
* fix: fix file handle path in FSA entries iterator

* Fix directory handle paths and add assertions
  • Loading branch information
quickgiant authored Mar 31, 2024
1 parent cf9b0b3 commit b8905eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node-to-fsa/NodeFileSystemDirectoryHandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle implemen
for (const d of list) {
const dirent = d as Dirent;
const name = dirent.name + '';
const newPath = path + ctx.separator! + name;
const newPath = path + name;
if (dirent.isDirectory()) yield [name, new NodeFileSystemDirectoryHandle(fs, newPath, ctx)];
else if (dirent.isFile()) yield [name, new NodeFileSystemFileHandle(fs, name, ctx)];
else if (dirent.isFile()) yield [name, new NodeFileSystemFileHandle(fs, newPath, ctx)];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ onlyOnNode20('NodeFileSystemDirectoryHandle', () => {
expect(subdir).toBeInstanceOf(NodeFileSystemDirectoryHandle);
expect(subdir.kind).toBe('directory');
expect(subdir.name).toBe('My Documents');
expect((subdir as NodeFileSystemDirectoryHandle).__path).toBe('/My Documents/');
}
});

Expand All @@ -76,6 +77,7 @@ onlyOnNode20('NodeFileSystemDirectoryHandle', () => {
expect(file).toBeInstanceOf(NodeFileSystemFileHandle);
expect(file.kind).toBe('file');
expect(file.name).toBe('file.txt');
await expect((file as NodeFileSystemFileHandle).getFile()).resolves.toBeInstanceOf(File);
}
});

Expand Down

0 comments on commit b8905eb

Please sign in to comment.