gulp.run已弃用。我如何撰写任务? [英] gulp.run is deprecated. How do I compose tasks?

查看:84
本文介绍了gulp.run已弃用。我如何撰写任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个复杂的任务,我不知道如何用任务依赖关系替换它。

  ... 
gulp.task('watch',function(){
var server = function(){
gulp.run('jasmine');
gulp.run('embed') ;
;
var client = function(){
gulp.run('scripts');
gulp.run('styles');
gulp。 run('copy');
gulp.run('lint');
};
gulp.watch('app / *。js',server);
gulp .watch('spec / nodejs / *。js',server);
gulp.watch('app / backend / *。js',server);
gulp.watch('src / admin / * .js',client);
gulp.watch('src / admin / *。css',client);
gulp.watch('src / geojson-index.json',function() {
gulp.run('copygeojson');
});
});

相应的更改日志
https://github.com/gulpjs/gulp/blob/master/CHANGELOG.md#35 [弃用gulp.run]

解决方案

gulp.task('watch',function(){
var server = [' jasmine','embed'];
var client = ['scripts','styles','copy','lint'];
gulp.watch('app / *。js',server );
gulp.watch('spec / nodejs / *。js',server);
gulp.watch('app / backend / *。js',server);
gulp。 ('src / admin / *。js',client);
gulp.watch('src / admin / *。css',client);
gulp.watch('src / geojson-index .json',['copygeojson']);
});

您不再需要传递一个函数(尽管您仍然可以)来运行任务。你可以看一组任务名称,它会为你做这件事。


Here is a composed task I don't know how to replace it with task dependencies.

...
gulp.task('watch', function () {
 var server = function(){
  gulp.run('jasmine');
  gulp.run('embed');
 };
 var client = function(){
  gulp.run('scripts');
  gulp.run('styles');
  gulp.run('copy');
  gulp.run('lint');
 };
 gulp.watch('app/*.js', server);
 gulp.watch('spec/nodejs/*.js', server);
 gulp.watch('app/backend/*.js', server);
 gulp.watch('src/admin/*.js', client);
 gulp.watch('src/admin/*.css', client);
 gulp.watch('src/geojson-index.json', function(){
  gulp.run('copygeojson');
 });
});

The corresponding changelog https://github.com/gulpjs/gulp/blob/master/CHANGELOG.md#35 [deprecate gulp.run]

解决方案

gulp.task('watch', function () {
  var server = ['jasmine', 'embed'];
  var client = ['scripts', 'styles', 'copy', 'lint'];
  gulp.watch('app/*.js', server);
  gulp.watch('spec/nodejs/*.js', server);
  gulp.watch('app/backend/*.js', server);
  gulp.watch('src/admin/*.js', client);
  gulp.watch('src/admin/*.css', client);
  gulp.watch('src/geojson-index.json', ['copygeojson']);
});

You no longer need to pass a function (though you still can) to run tasks. You can give watch an array of task names and it will do this for you.

这篇关于gulp.run已弃用。我如何撰写任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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