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 support to pass in fs interface #280

Closed
ghost opened this issue Aug 8, 2016 · 9 comments
Closed

Add support to pass in fs interface #280

ghost opened this issue Aug 8, 2016 · 9 comments

Comments

@ghost
Copy link

ghost commented Aug 8, 2016

I enjoy node-glob, but I need its use on a virtual file system which is separate from the node fs, but with the same interface. If we modify fs.realpath and add in a fs parameter in the options which falls back to the default native fs t should be quite easy

@erikkemperman
Copy link
Contributor

That would be exactly what I was looking for! Currently vinyl-fs is being updated to split off a module for use by other vinyl adapters, vinyl-prepare. With any luck it'll be in Gulp 4.

It would be great if implementers of custom vinyl adapters, such as purely in-memory ones, would not have to do their own globbing (or disallow glob patterns completely) -- but instead just provide the needed subset of fs calls as an option.

At this time, our call to glob can't be transplanted to vinyl-prepare because of its file system access, but I think it should be.

@isaacs I'd be willing to spend some time on a PR, unless of course you don't like the idea to begin with?

@erikkemperman
Copy link
Contributor

erikkemperman commented Aug 31, 2016

Come to think of it, maybe folks would like to use graceful-fs, that would also be easy with something like the above in place.

EDIT Scratch that last bit, I just found #71.

erikkemperman added a commit to erikkemperman/node-glob that referenced this issue Sep 5, 2016
erikkemperman added a commit to erikkemperman/node-glob that referenced this issue Sep 6, 2016
erikkemperman added a commit to erikkemperman/node-glob that referenced this issue Sep 6, 2016
@erikkemperman
Copy link
Contributor

@Auxolust I've submitted a PR that would address my use case... And yours, I believe?

Sorry about the repeated references above, I cleaned up the accompanying test a little bit and force-pushed to override the previous commit. But since it already had the issue number in there, this happened.

erikkemperman added a commit to erikkemperman/node-glob that referenced this issue Sep 7, 2016
@blond blond mentioned this issue Oct 8, 2016
@blond
Copy link

blond commented Oct 8, 2016

Come to think of it, maybe folks would like to use graceful-fs, that would also be easy with something like the above in place.

@erikkemperman there are reasons to use graceful-fs: #299

@millette
Copy link

millette commented Dec 3, 2017

I've got a small patch too so I can use glob with dat and hyperdrive and it seems to work for me so far. Basically, I can now use glob like this:

// dat.archive is a hyperdrive instance
glob('*', { cwd: '/', fs: dat.archive), (err, files) => {
  // and voilà
})

@martinheidegger
Copy link

I was looking at this issue exactly because of how to use it with hyperdrive and plan to use the small patch by @millette . Total 👍 by me for having this. Would it be okay to publish a PR based on this prior work?

@ajafff
Copy link

ajafff commented Sep 17, 2018

To anyone who also wants to use a custom fs implementation without patching glob as described above: I created a package that allows intercepting file system access: https://www.npmjs.com/package/glob-interceptor

Caveat: it only works with synchronous IO.

@resistdesign
Copy link

Wow, this has been here for a while.

@isaacs
Copy link
Owner

isaacs commented Mar 1, 2023

If this is added to https://github.com/isaacs/path-scurry, then glob will pass the requisite options along. Glob doesn't actually touch the file system directly any more, everything goes through PathScurry.

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

7 participants