我的 gulpfile.js 的一部分
Part of my gulpfile.js
const del = require('del');
const chrome_dir = 'build/chrome';
const ff_dir = 'build/firefox';
gulp.task('clean', function (cb) {
del([chrome_dir, ff_dir], cb);
});
gulp.task('default', ['clean'], function () {
gulp.start('build packages', 'JS Backend', 'i18n', 'ExtRes', 'styles', 'JS Content', 'templates');
});
效果很好.
然后我安装了一个新系统,可能会有新版本的 gulp 和 del 等等.
现在 gulp 在清洁后停止.
我可以手动调用所有任务,效果很好.
只能是改变del的行为...
worked well.
Then I installed a new system and there maybe got new versions of gulp and del and whatever.
Now gulp stops after cleaning.
I can call all tasks manually, that's working fine.
Could only be a change in the behaviour of del...
我该如何解决这个问题?
How can I fix this?
v2 最重要的变化之一是它现在返回一个 Promise 而不是使用回调来处理异步.来自 del 文档.
One of the most important changes on v2 is that now it returns a Promise instead of using a callback to handle async. From del documentation.
您只需重新编写这部分代码:
You simply have to re-write this part of your code:
gulp.task('clean', function (cb) {
del([chrome_dir, ff_dir], cb);
});
像这样:
gulp.task('clean', function () {
return del([chrome_dir, ff_dir]);
});
这篇关于Gulp clean/del 行为已经改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Browserify,Babel 6,Gulp - 传播运算符上的意外令牌Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 传播运算符上的意外令牌)
是否可以将标志传递给 Gulp 以使其以不同的方式Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以将标志传递给 Gulp 以使其以不同的方式运行任务
为什么我们需要在全局和本地安装 gulp?Why do we need to install gulp globally and locally?(为什么我们需要在全局和本地安装 gulp?)
如何一个接一个地依次运行 Gulp 任务How to run Gulp tasks sequentially one after the other(如何一个接一个地依次运行 Gulp 任务)
由于 MIME 类型而未加载样式表Stylesheet not loaded because of MIME-type(由于 MIME 类型而未加载样式表)
打开 Javascript 文件时 Visual Studio 2015 崩溃Visual Studio 2015 crashes when opening Javascript files(打开 Javascript 文件时 Visual Studio 2015 崩溃)