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

Add fs option to allow passing virtual filesystem #430

Closed
wants to merge 2 commits into from

Conversation

mmkal
Copy link
Contributor

@mmkal mmkal commented Nov 18, 2020

Fixes #429


This enables passing in a virtual filesystem compatible with the fs module. There are several matching the fs API:

Example:

let glob = require('glob')
let memfs = require('memfs')

let volume = memfs.Volume.fromJSON({
  '/foo/bar/abc.txt': 'abc',
  '/foo/bar/def.log': 'def',
  '/foo/bar/xyz.txt': 'xyz',
})

glob.sync('/foo/bar/*.txt', { fs: volume }) // returns ['/foo/bar/abc.txt', '/foo/bar/xyz.txt']

Allows usage of glob in lots more places without requiring users to monkey-patch. With this change, glob could be used in the browser, with dropbox, S3, purely in memory like above (useful for testing) and many others.


After writing that issue up, I had a look at the code and the change required is very small so I thought I'd just open a PR.

@isaacs isaacs closed this in df4598a Sep 22, 2021
@isaacs
Copy link
Owner

isaacs commented Sep 23, 2021

Thanks, landed and published as 7.2.0

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

Successfully merging this pull request may close these issues.

Virtual file system option?
2 participants