Gulp globbing-如何查看目录下的所有内容

这是一个非常愚蠢的问题,但是我还没有找到一个令人满意的答案: 我如何使用 Gulp globbing 来选择某个目录下 所有子目录中的 所有文件?

我试过了:

'./src/less' './src/less/' './src/less/*'

看起来都不管用。

88269 次浏览

'./src/less/**' seems to work. Still, if someone has a more definitive list of all globbing commands, I would be happy to accept your answer and add it to the gulp docs. Right now you have to go to the docs for one of gulp's submodules, which then gives you a list of manpages. It would be good to have a direct reference, especially for designers using gulp.

The pattern for all files under all directories is usually ./src/less/**/*.* or ./src/less/**/*, either should work.

Generally speaking, it's better to match specific files extensions — even if they should all be the same — to prevent grabbing system files or other junk. In that case, you can do ./src/less/**/*.less for just .less files, or something like .src/less/**/*.{less,css} for both .less and .css files.

The Grunt website has a pretty good reference for the majority of minimatch globs. (Both Grunt and gulp use minimatch, since it's the glob library for pretty much everything Node related.)

It would be nice for gulp or minimatch to have their own complete docs, but that's open source for you.