Javascript 除 .spec.js 之外的每个 .js 文件的节点 glob 模式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26639236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Node glob pattern for every .js file except .spec.js
提问by roughcoder
I am looking for a better glob pattern for usemin, i want to to find all .jsfiles but exclude the .spec.jsfiles. I have the following solution so far.
我正在为 usemin 寻找更好的 glob 模式,我想查找所有.js文件但排除.spec.js文件。到目前为止,我有以下解决方案。
<script src="components/**/*(.js|!(*.spec.js|*.scss))"></script>
<script src="components/**/*(.js|!(*.spec.js|*.scss))"></script>
The solution i have at the moment requires me to keep adding file extensions to exclude them, else they get picked up, for example .htmlfiles.
我目前的解决方案要求我不断添加文件扩展名以排除它们,否则它们会被拾取,例如.html文件。
I tried to make it only look for .jsfiles and exclude the .spec.jsfrom them but it does not seem to work.
我试图让它只查找.js文件并.spec.js从它们中排除,但它似乎不起作用。
Also adding a !components/**/*.spec.jsas another script below does not seem to work.
另外!components/**/*.spec.js在下面添加一个作为另一个脚本似乎不起作用。
回答by Heikki
This glob includes all *.jsbut not *.spec.js:
这个 glob 包括所有*.js但不包括*.spec.js:
components/**/!(*.spec).js

