问题描述
我需要使用Grunt.js删除目录中所有具有特定文件扩展名的文件及其所有子目录,我想我可能需要一个模块才能这样做?我看过干净,但似乎是删除整个目录,而不是具体的文件。
我的目录看起来像:
- build / img /
- build / img / ico
- build / img / li>
以及我想要删除的文件扩展名是:
.png〜
, .gif〜
或 .jpg扩展名
任何想法? 可以配置 grunt-contrib-clean
任务删除这些文件:
clean :{
yourTarget:{
src:[build / img / ** / *。png〜,
build / img / ** / *。gif〜,
build / img / ** / *。jpg〜
}
}
请参阅文档的以获取 **
, *
以及其他符合条件的模式。
I need to delete all files with a specific file extension in a directory and all of its sub-directories using Grunt.js and I guess I probably need a module to do so? I've looked at clean but that seems to be for deleting whole directories rather than specific files.
My directory looks like:
- build/img/
- build/img/ico
- build/img/logos
and the file extension I want to delete is:
Any file with the extension of .png~
, .gif~
or .jpg~
Any ideas?
You can configure the grunt-contrib-clean
task to remove those files like this:
clean : {
yourTarget : {
src : [ "build/img/**/*.png~",
"build/img/**/*.gif~",
"build/img/**/*.jpg~"
]
}
}
See this section of the docs for an explanation of **
, *
, and other globbing patterns.
这篇关于Grunt - 删除具有特定文件扩展名的子目录中的所有文件和文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!