Skip to content

Commit

Permalink
Remove outdated tests and prevent directory descriptor from being rea…
Browse files Browse the repository at this point in the history
…d if it is closed.
  • Loading branch information
Kapelianovych committed Nov 17, 2023
1 parent 97afe98 commit 44a73b0
Show file tree
Hide file tree
Showing 27 changed files with 47 additions and 3,989 deletions.
11 changes: 11 additions & 0 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ import AsyncIterable from "@halo-lab/iterable/async";
* closes automatically.
*/
export function walkDirectory(path, recursive = true) {
let isClosed = false;
const openedInnerDirectories = [];

const openDirectoryRequest = opendir(path);

const files = AsyncIterable.from(async function* () {
if (isClosed) {
return;
}

const directory = await openDirectoryRequest;

for await (const dirent of directory) {
Expand All @@ -41,13 +46,19 @@ export function walkDirectory(path, recursive = true) {
return {
files,
async close() {
if (isClosed) {
return;
}

const directory = await openDirectoryRequest;

await directory.close();

await Promise.all(
openedInnerDirectories.map((descriptor) => descriptor.close()),
);

isClosed = true;
},
};
}
113 changes: 0 additions & 113 deletions test/bundler/cache.js

This file was deleted.

215 changes: 0 additions & 215 deletions test/bundler/globalApi.js

This file was deleted.

Loading

0 comments on commit 44a73b0

Please sign in to comment.