Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does this pattern work: 'test/e2e/**/*.spec.js'?

I saw this pattern used in a configuration file for protractor.

specs: [
  'test/e2e/**/*.spec.js'
]

To mean it means "all files inside test/e2e". What kind of pattern is this? I think it's not regex because of those unescaped slashes. Especially, why is there ** in the middle, not just test/e2e/*.spec.js?

I tried using the search engine, but did not find anything useful probably because the asterisks don't work very well in search engines.

like image 613
user69715 Avatar asked Dec 31 '15 22:12

user69715


1 Answers

What kind of pattern is this?

It is called "glob". The module glob is a popular implementation for Node, and appears to be the one used by Protractor.

Especially, why is there "**" in the middle, not just "test/e2e/*.spec.js"?

** means it can match sub-directories. It's like a wildcard for sub-directories.

For example, test/e2e/*.spec.js would match test/e2e/example.spec.js, but not test/e2e/subdir/example.spec.js. However test/e2e/**/*.spec.js matches both.

like image 123
Alexander O'Mara Avatar answered Sep 21 '22 22:09

Alexander O'Mara