【问题标题】:Glob / minimatch: How to get sub folders?Glob / minimatch:如何获取子文件夹?
【发布时间】:2019-01-04 23:54:10
【问题描述】:

我想将 Bower 组件的完整文件夹结构(没有第一级文件)复制到我的 Web 项目中。

源项目的结构如下所示:

bower_components/roboto-fontface-bower/css/
bower_components/roboto-fontface-bower/fonts/
bower_components/roboto-fontface-bower/.bower.json
bower_components/roboto-fontface-bower/bower.json
bower_components/roboto-fontface-bower/LICSENSE
bower_components/roboto-fontface-bower/package.json
bower_components/roboto-fontface-bower/README.md

我想获取文件夹css(包含文件)和fonts(包含文件)。

我当前的minimatch 模式是:

"bower_components/roboto-fontface-bower/**"

使用我当前的模式,文件.bower.jsonbower.json 等也会被复制,这是我不想要的。我怎样才能只获取这两个文件夹(css & fonts)?

我尝试了"bower_components/roboto-fontface-bower/{css/,fonts/}",但这并没有复制任何内容。

【问题讨论】:

  • bower_components/roboto-fontface-bower/(css|fonts)/ 怎么样?不过我对 minimatch 不熟悉,所以也许这行不通。
  • 感谢您的快速回答,但这根本没有复制 roboto-fontface-bower 文件夹。 :'(
  • 我不确定迷你匹配是如何工作的,所以这可能不在我的范围内。使用这个正则表达式,应该返回 css 和 fonts 目录,这不是您所追求的还是还有更多?

标签: regex npm bower glob minimatch


【解决方案1】:

试试bower_components/roboto-fontface-bower/{css,fonts}/*

您可以使用globster.xyz对其进行测试

【讨论】:

    猜你喜欢
    • 2012-09-19
    • 2014-12-16
    • 2019-12-26
    • 2014-01-21
    • 1970-01-01
    • 2013-06-14
    • 1970-01-01
    • 1970-01-01
    • 2014-03-20
    相关资源
    最近更新 更多