Gulp:如何删除文件夹? [英] Gulp: how to delete a folder?

查看:308
本文介绍了Gulp:如何删除文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用del包删除文件夹:

I use del package to delete folder:

gulp.task('clean', function(){
    return del('dist/**/*', {force:true});
});

但是,如果dist文件夹中有很多子目录,而我想删除dist文件夹及其所有文件,是否有任何简单的方法?

But if there are many subdirectory in dist folder and I want to delete dist folder and all its files, is there any easy way to do it?

Ps:我不想这样做:dist/**/**/**/**/**/**/...当子目录太多时.

Ps: I don't want to do in this way: dist/**/**/**/**/**/**/... when there are so many subdirectories.

推荐答案

您的代码应如下所示:

gulp.task('clean', function(){
     return del('dist/**', {force:true});
});

根据npm del docs"**"删除dist的所有子目录(ps:请勿删除dist文件夹):

according to the npm del docs "**" deletes all the subdirectories of dist (ps: don't delete dist folder):

全局模式 ** 匹配所有子代和父代."

"The glob pattern ** matches all children and the parent."

参考

这篇关于Gulp:如何删除文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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