Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readSite does not work with alternate fs implementations #5

Open
lachenmayer opened this issue Feb 26, 2018 · 0 comments
Open

readSite does not work with alternate fs implementations #5

lachenmayer opened this issue Feb 26, 2018 · 0 comments

Comments

@lachenmayer
Copy link
Contributor

const archive = new DatArchive('dat://enoki.site/')
const site = await hypha.readSite('content/', { fs: archive })

fails in Beaker with:

index.js:2784 Uncaught (in promise) TypeError: fs.readdir is not a function
    at Glob._readdir (index.js:2784)
    at Glob._processGlobStar (index.js:2862)
    at Glob._process (index.js:2600)
    at new Glob (index.js:2407)
    at glob (index.js:2312)
    at P (index.js:28455)
    at Promise (<anonymous>)
    at index.js:28417
    at ret (index.js:28478)
    at Object.readSite (index.js:20362)

That's because glob does not support custom fs implementations, ie. it just requires fs straight up. There's a PR from 2016(!!!) (isaacs/node-glob#285) to allow custom fs to be passed in to glob, but it hasn't been merged and it looks like it's not going to be updated any time soon.

Considering that the glob is literally just **/*, we could use something like recursive-readdir instead. This also does not allow passing in fs, but the chances of adding that looks straightforward & much more likely to be merged.

Alternatively, we could just write our own implementation based on recursive-readdir, don't think that's a good idea but it would be forward progress...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant