Gulp 只有当因果报应测试任务成功吞咽时,如何运行第二个任务?
我在喝啤酒。我有一个Gulp 只有当因果报应测试任务成功吞咽时,如何运行第二个任务?,gulp,gulp-karma,Gulp,Gulp Karma,我在喝啤酒。我有一个deploy任务,它在test任务之后运行。问题是即使测试失败,deploy任务也会运行。只有在gulp中测试成功时,才有办法运行deploy任务吗 gulp.task('test', function() { return gulp.src('some_test_tile') .pipe(karma({ configFile: 'karma.conf.js', action: 'run' })); }); gulp.task('
deploy
任务,它在test
任务之后运行。问题是即使测试失败,deploy
任务也会运行。只有在gulp中测试成功时,才有办法运行deploy
任务吗
gulp.task('test', function() {
return gulp.src('some_test_tile')
.pipe(karma({
configFile: 'karma.conf.js',
action: 'run'
}));
});
gulp.task('deploy', ['test'], function() {
return gulp.src(paths.scripts)
.pipe(gulp.dest(paths.dest));
});
我正在使用
gulp karma
运行karma测试。您的任务是否在依赖项完成之前运行?确保依赖项任务正确使用异步运行提示
如果其fn
执行以下操作之一,则可以使任务异步:
- 接受回拨
- 返流
- 还愿
该命令要求在管道到karma之后添加.on('error',…),并手动抛出错误,以确保在任何测试失败时gulp退出非零。这应该就够了。您对karma使用的测试框架是什么?当测试失败时,您的框架是否可能引发异常?我相信这会阻止后续的吞咽任务运行。
var gulp = require('gulp');
// takes in a callback so the engine knows when it'll be done
gulp.task('one', function (cb) {
// do stuff -- async or otherwise
cb(err); // if err is not null and not undefined, the run will stop, and note that it failed
});
// identifies a dependent task must be complete before this one begins
gulp.task('two', ['one'], function () {
// task 'one' is done now
});
gulp.task('default', ['one', 'two']);