Skip to content

readSite does not work with alternate fs implementations #5

@lachenmayer

Description

@lachenmayer
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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions