unstorage icon indicating copy to clipboard operation
unstorage copied to clipboard

[fs] `getKeys` does not works for mounts within `node_modules`

Open pi0 opened this issue 1 year ago • 2 comments

Environment

Reproduction

Mount a driver within node_modules path.

Describe the bug

https://github.com/unjs/unstorage/blob/0e2ea339a65995c9ef1e2130a293f0928a2c9de1/src/drivers/fs.ts#L32

Additional context

No response

Logs

No response

pi0 avatar Sep 04 '24 17:09 pi0

"Today bug". Yesterday my script working perfectly fine.

Today, with this:

const storage = createStorage({
	driver: fsDriver({ base: "./" }),
});

const packages = await storage.getKeys();

I got:

file:///home/oritwoen/Projekty/Archex/node_modules/.pnpm/[email protected]/node_modules/unstorage/drivers/utils/node-fs.mjs:39
    entries.map(async (entry) => {
            ^

TypeError: entries.map is not a function
    at readdirRecursive (file:///home/oritwoen/Projekty/Archex/node_modules/.pnpm/[email protected]/node_modules/unstorage/drivers/utils/node-fs.mjs:39:13)
    at async file:///home/oritwoen/Projekty/Archex/node_modules/.pnpm/[email protected]/node_modules/unstorage/drivers/utils/node-fs.mjs:42:26
    at async Promise.all (index 2)
    at async readdirRecursive (file:///home/oritwoen/Projekty/Archex/node_modules/.pnpm/[email protected]/node_modules/unstorage/drivers/utils/node-fs.mjs:38:3)
    at async file:///home/oritwoen/Projekty/Archex/node_modules/.pnpm/[email protected]/node_modules/unstorage/drivers/utils/node-fs.mjs:42:26
    at async Promise.all (index 43)
    at async readdirRecursive (file:///home/oritwoen/Projekty/Archex/node_modules/.pnpm/[email protected]/node_modules/unstorage/drivers/utils/node-fs.mjs:38:3)
    at async Object.getKeys (file:///home/oritwoen/Projekty/Archex/node_modules/.pnpm/[email protected]/node_modules/unstorage/dist/index.mjs:314:25)
    at async file:///home/oritwoen/Projekty/Archex/build.mjs:10:18

oritwoen avatar Sep 05 '24 15:09 oritwoen

@oritwoen i'm not sure it is the same issue... And also this stackblitz works with latest version.

If you could make a reproduction, please open a new issue 🙏🏼

pi0 avatar Sep 05 '24 15:09 pi0