Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/423.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在minimatch中一次性匹配html或js?_Javascript_Node.js_Glob - Fatal编程技术网

Javascript 如何在minimatch中一次性匹配html或js?

Javascript 如何在minimatch中一次性匹配html或js?,javascript,node.js,glob,Javascript,Node.js,Glob,我正在为GulpWatch编写glob模式,并希望在每个html或js更改上重新构建 # my first variant > minimatch('src/app/app.js', 'src/app/**/*.(js|html)') false # not working > minimatch('src/app/app.js', 'src/app/**/*.+(js|html)') true # this works > minimatch('src/app/app.jsj

我正在为GulpWatch编写glob模式,并希望在每个html或js更改上重新构建

# my first variant
> minimatch('src/app/app.js', 'src/app/**/*.(js|html)')
false # not working
> minimatch('src/app/app.js', 'src/app/**/*.+(js|html)')
true # this works
> minimatch('src/app/app.jsjs', 'src/app/**/*.+(js|html)')
true
# but also this works:
> minimatch('src/app/app.jsjsjsjsjs', 'src/app/**/*.+(js|html)')
true

如何正确地在中执行,意思是只匹配html或js一次,就像在正则表达式中一样?

您要求它匹配一个或多个
(.js |.html)
您需要使用
@
只匹配一个

minimatch('src/app/app.js', 'src/app/**/*.@(js|html)')

您要求它匹配一个或多个
(.js |.html)
您需要使用
@
只匹配一个

minimatch('src/app/app.js', 'src/app/**/*.@(js|html)')

看起来您可以使用以下选项:

minimatch('src/app/app.js', 'src/app/**/*.{js,html}')

看起来您可以使用以下选项:

minimatch('src/app/app.js', 'src/app/**/*.{js,html}')