unjs / unstorage

💾 Unstorage provides an async Key-Value storage API with conventional features like multi driver mounting, watching and working with metadata, dozens of built-in drivers and a tiny core.
https://unstorage.unjs.io
MIT License
1.86k stars 138 forks source link

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

Open pi0 opened 2 months ago

pi0 commented 2 months ago

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

oritwoen commented 2 months ago

"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/unstorage@1.11.1/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/unstorage@1.11.1/node_modules/unstorage/drivers/utils/node-fs.mjs:39:13)
    at async file:///home/oritwoen/Projekty/Archex/node_modules/.pnpm/unstorage@1.11.1/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/unstorage@1.11.1/node_modules/unstorage/drivers/utils/node-fs.mjs:38:3)
    at async file:///home/oritwoen/Projekty/Archex/node_modules/.pnpm/unstorage@1.11.1/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/unstorage@1.11.1/node_modules/unstorage/drivers/utils/node-fs.mjs:38:3)
    at async Object.getKeys (file:///home/oritwoen/Projekty/Archex/node_modules/.pnpm/unstorage@1.11.1/node_modules/unstorage/dist/index.mjs:314:25)
    at async file:///home/oritwoen/Projekty/Archex/build.mjs:10:18
pi0 commented 2 months ago

@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 🙏🏼