diff --git a/package-lock.json b/package-lock.json index c535424..cefba1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "browser-fs-access", - "version": "0.32.0", + "version": "0.32.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "browser-fs-access", - "version": "0.32.0", + "version": "0.32.1", "license": "Apache-2.0", "devDependencies": { "eslint": "^8.34.0", diff --git a/package.json b/package.json index 791b82d..ad3d827 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "browser-fs-access", - "version": "0.32.0", + "version": "0.32.1", "description": "File System Access API with legacy fallback in the browser.", "type": "module", "source": "./src/index.js", diff --git a/src/fs-access/directory-open.mjs b/src/fs-access/directory-open.mjs index 02c338d..ec5ae0e 100644 --- a/src/fs-access/directory-open.mjs +++ b/src/fs-access/directory-open.mjs @@ -60,11 +60,10 @@ export default async (options = {}) => { startIn: options.startIn, mode: options.mode, }); - const files = getFiles( - handle, - options.recursive, - undefined, - options.skipDirectory - ); - return handle.values ? files : [handle]; + // If the directory is empty, return an array with the handle. + if ((await (await handle.values()).next()).done) { + return [handle]; + } + // Else, return an array of File objects. + return getFiles(handle, options.recursive, undefined, options.skipDirectory); };