Gulp - 定位文件夹及其子文件夹中的所有文件 [英] Gulp - Target all files in a folder and its subfolders

查看:544
本文介绍了Gulp - 定位文件夹及其子文件夹中的所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够将 gulp 中的 watch 任务添加到所有 frontend / js 以及其他任何js文件

I'd like to be able to add a watch task in gulp to all of the js files in the frontend/js and any other js files below

 gulp.watch('./frontend/js/**/*.js', ['browserify']);

这将只针对 js 个文件夹

推荐答案

它应该匹配任意数量的子目录:

It's supposed to match any number of subdirectories:


** 如果一个globstar在路径部分单独存在,那么它匹配零个或多个目录和子目录搜索匹配。它不抓取符号链接的目录。

** If a "globstar" is alone in a path portion, then it matches zero or more directories and subdirectories searching for matches. It does not crawl symlinked directories.

https://github.com/isaacs/node-glob

你有那里的符号链接目录吗?

Do you have symlinked directories in there?

我认为你不会在本地遍历你的符号链接目录。我建议你看看 node.js fs.readdir递归目录搜索并查看是否有任何这些解决方案可以应用于您的用例。问题或答案中没有任何内容专门用于符号链接,因此我不知道您是否有解决方案。如果您可以使用其中一种解决方案获取解引用的路径名数组,那么您可以将数组传递给 gulp.src()

I don't think you'll get gulp to natively traverse your symlinked directories. I recommend you take a look at node.js fs.readdir recursive directory search and see if any of those solutions can be applied to your use case. Nothing in the question or answers specifically addresses symlinks, so I don't know if there's a solution for you there or not. If you can get an array of dereferenced pathnames using one of those solutions, then you can just pass the array to gulp.src().

这篇关于Gulp - 定位文件夹及其子文件夹中的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆