Gulp clean / del行为已经改变 [英] Gulp clean / del behaviour has changed

查看:193
本文介绍了Gulp clean / del行为已经改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

部分我的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);
});

$ b gulp.task('default',['clean'],function(){
gulp.start('build packages','JS Backend','i18n ','ExtRes','styles','JS Content','templates');
});

运作良好。

然后我安装了一个新系统, gulp和del和其他任何版本。

现在gulp在清理后停止。

我可以手动调用所有任务,工作正常。

只能是一个改变行为的del ...



我该如何解决这个问题?

解决方案

v2 上最重要的变化之一就是它现在返回一个 Promise 而不是使用回调 em>处理异步。从 del 文档



您只需重新编写代码的这一部分:

  gulp.task('clean',function(cb){
del([chrome_dir,ff_dir],cb);
});

像这样:

  gulp.task('clean',function(){
return del([chrome_dir,ff_dir]);
});


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');
});

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?

解决方案

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);
});

like this:

gulp.task('clean', function () {
    return del([chrome_dir, ff_dir]);
});

这篇关于Gulp clean / del行为已经改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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