By Jwan622


2015-09-16 09:28:04 8 Comments

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

4 comments

@paxdiablo 2015-09-16 09:31:16

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

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

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

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

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

with the concept of "any number of levels" also including zero (in other words, /x/**/y will match /x/y as one of its choices).


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

@AleksandrH 2018-08-27 01:21:58

This makes no sense. If * denotes 0 or more characters, then that pattern could potentially match /x//y, which is nonsensical. What you're really saying is "any number of characters, followed by any number of characters". Isn't that just... oh, I don't know... any number of characters???

@paxdiablo 2018-08-27 01:44:54

@AleksandrH, no, this isn't a regex in the normal sense: there's no matching of characters, only directory names. This is specifically for hierarchical file systems. On your first point, if empty directory names were allowed, /x//y would be perfectly valid. I've never seen a file system that allows this however. On your second point, the * means match "any directory name, one level only" (so won't go beyond the next / divider) while ** means "match any number of levels with any directory name at each level" (can cross over as many / dividers as needed).

@AleksandrH 2018-08-27 11:03:40

Okay, I see, thanks for clarifying

@Yassine Imounachen 2019-03-18 18:09:02

It's worth noting that for /x/**/y/, /x/y/ is also included, which is neat.

@Thomas S. 2015-09-16 09:30:37

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

@Sean 2015-09-16 09:32:10

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

@Simon East 2017-10-13 06:06:47

A single asterisk would also match your examples. I think you meant to include an additional sub-subdirectory to your second example.

@AutumnSky 2019-01-25 15:26:11

@SimonEast like this? src/js/files/controllers/user.js, src/js/files/models/foo/var.js

@ShivangiBilora 2015-09-16 09:31:46

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

Related Questions

Sponsored Content

24 Answered Questions

[SOLVED] How to use glob() to find files recursively?

2 Answered Questions

[SOLVED] Running gulp task from one gulpfile.js from another gulpfile.js

1 Answered Questions

[SOLVED] Any way in Gulp to get matched glob pattern in stream?

  • 2019-03-31 23:40:59
  • calligraphic-io
  • 152 View
  • 1 Score
  • 1 Answer
  • Tags:   gulp

2 Answered Questions

[SOLVED] gulp minify all css files to a single file

1 Answered Questions

[SOLVED] Run one gulp task on multiple folders. The folders look like plugins/lsmwp-*

  • 2018-08-08 12:38:30
  • James Husband
  • 158 View
  • 0 Score
  • 1 Answer
  • Tags:   gulp

1 Answered Questions

[SOLVED] dynamic src in gulp tasks

1 Answered Questions

[SOLVED] How can I get gulp-typescript to output to the same directory as the source file?

  • 2015-04-08 02:49:41
  • Richard Collette
  • 4670 View
  • 10 Score
  • 1 Answer
  • Tags:   typescript gulp

2 Answered Questions

[SOLVED] Gulp copying empty directories

1 Answered Questions

[SOLVED] Glob matching, exclude all JS files

Sponsored Content