What is the ** glob character?

2019-01-11 08:20发布

I have this path in my react gulpfile:

var path = {
  HTML: 'src/index.html',
  ALL: ['src/js/*.js', 'src/js/**/*.js', 'src/index.html'],
  JS: ['src/js/*.js', 'src/js/**/*.js'],
  MINIFIED_OUT: 'build.min.js',
  DEST_SRC: 'dist/src',
  DEST_BUILD: 'dist/build',
  DEST: 'dist'
};

What is the double glob character?

I know what the single glob is... but what is the double? single glob

标签: gulp glob
4条回答
趁早两清
2楼-- · 2019-01-11 09:10

Like Grunt, the double ** is saying, "Look in all the subfolders within js and for all of the .js files."

You can actually refer here for the same:

https://www.codefellows.org/blog/quick-intro-to-gulp-js

查看更多
甜甜的少女心
3楼-- · 2019-01-11 09:14

It's almost the same as the single asterisk but may consist of multiple directory levels.

In other words, while /x/*/y will match:

/x/a/y
/x/b/y

and so on (only one directory level in the wildcard section), the double asterisk /x/**/y will also match things like:

/x/any/number/of/levels/y

As an aside, as much as I hate to credit the mainframe with anything, I believe this has been used since the earlist days of MVS to allow selection of datasets at multiple levels.

查看更多
【Aperson】
4楼-- · 2019-01-11 09:17

It's usually used to indicate any number of subdirectories. So

src/js/**/*.js

Would match

src/js/files/*.js
src/js/more-files/*.js

etc
etc
查看更多
爷的心禁止访问
5楼-- · 2019-01-11 09:20

** matches any character including a forward-slash /
* matches any character except a forward-slash (to match just the file or directory name)

查看更多
登录 后发表回答