Match multiple file extensions in npm script

空扰寡人 提交于 2019-12-10 13:25:32

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/45949796/match-multiple-file-extensions-in-npm-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!