Skip to content

support function-type options.ignore #261

@kaelzhang

Description

@kaelzhang

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)
})

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