Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Match multiple file extensions in npm script

I have an npm script where I want to match both ts and tsx file extensions... something like below:

"test": "mocha ..... app/test/**/*.spec.{ts,tsx}"

However, the above syntax doesn't work. What's the correct syntax for doing this?

like image 340
sir_thursday Avatar asked Aug 29 '17 23:08

sir_thursday


1 Answers

Your pattern is correct. Your problem is that your shell is attempting to expand your glob for you instead of letting mocha expand it.

To fix this, you need to double-quote your glob (note that double-quotes must be JSON-escaped with \):

"test": "mocha ..... \"app/test/**/*.spec.{ts,tsx}\""

Single quotes will also work (and won't need JSON-escaped) if you don't care about Windows support.

like image 69
RyanZim Avatar answered Sep 23 '22 21:09

RyanZim