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

support function-type options.ignore #261

Closed
kaelzhang opened this issue May 19, 2016 · 3 comments
Closed

support function-type options.ignore #261

kaelzhang opened this issue May 19, 2016 · 3 comments

Comments

@kaelzhang
Copy link

kaelzhang commented May 19, 2016

Is it possible for node-glob to support function-type options.ignore ?

Case

If we want to list all files according to the .gitignore, and the .gitignore file is:

node_modules/*
!node_modules/dir-to-be-included/

Suppose there are thousands of things inside node_modules, we should filter out those useless directories at the certain stage of glob and not after globbing, or the matching process of glob will be very slow.

But it is not that easy to use glob pattern to imitate the behavior of gitignore.

Proposal

glob('**/*', {
  ignore: function(path){
     return whetherShouldIgnoreByGitignore(path) 
     // Pay attention that gitignore patterns are not glob patterns
  }
}, (err, files) => {
  doThingsWith(files)
})
@kaelzhang
Copy link
Author

If it is ok to do this, I can help with pr.

@kaelzhang
Copy link
Author

@isaacs May I have any suggestions?

@isaacs
Copy link
Owner

isaacs commented Feb 28, 2023

This is a good feature request for v9, but supporting it on v8 was too terrible to consider.

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

2 participants