Skip to content

Option to only return files #33

@sindresorhus

Description

@sindresorhus

Currently, globby or rather glob returns both directories and files. You can turn off returning directories using the nodir: true glob option, but that's not what you want. You'd rather want to expand directories into files. That's what this option should do. So globby.sync('foo') where foo is a directory would be expanded into all the files in that directory that doesn't match any of the ignore patterns. Same with globby.sync('foo/**'). There also needs to be a way to specify an array of extensions. In many cases you wouldn't want the expansion to happen for all files, but, for example, just .js files. It should override the nodir option if specified by the user.

This would be useful and simplify code in AVA, XO, cpy, imagemin-cli, and other tools expecting files. For example: https://github.com/avajs/ava-files/blob/master/index.js#L212-L271

@UltCombo @schnittstabil @jamestalmage @SamVerschueren @novemberborn Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions