沉默地失败 - 没有错误印在控制台上 [英] gulp silently failing - no errors printed to console
本文介绍了沉默地失败 - 没有错误印在控制台上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的gulp文件没有在gulp.src()等标准gulp方法上发出任何错误,而且它们的处理程序也不会调用流错误。我已经包含一个简单的文件,默默地失败,只打印开始..并完成..默认消息。
My gulp file is not emitting any errors on either standard gulp methods like gulp.src() with non existant paths nor are stream errors being called by their handler. I've included a simple file that silently fails, printing only the starting.. and finished.. default messages.
var //
gulp = require( "gulp" ),
gulpUtil = require( "gulp-util" ),
sass = require( "gulp-ruby-sass");
gulp.task( "default", function() {
gulp.src( "path-that-does-not-exist.scss" )
.pipe( sass() )
.on( "error", function( err ) {
console.log( "this should print" );
})
.pipe( gulp.dest( "./client-side/public/compiled" ) );
});
推荐答案
好的,Gulp正在正确地工作。但是,我听到你的问题是,如果Gulp可以告诉你一个文件是否存在,它将会很好。
Okay, so Gulp is working "correctly." But what I'm hearing in your question is that it would be nice if Gulp could just tell you if a file doesn't exist.
我使用 gulp-expect-file 等等。
I use gulp-expect-file as such
var coffee = require('gulp-coffee');
var expect = require('gulp-expect-file');
gulp.task('mytask', function() {
var files = ['idontexist.html'];
return gulp.src(files)
.pipe(expect(files))
.pipe(coffee());
});
现在你会在终端中看到这个:
Now you'll see this in the terminal:
这篇关于沉默地失败 - 没有错误印在控制台上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文