gulp 静默失败 - 没有错误打印到控制台 [英] gulp silently failing - no errors printed to console

查看:46
本文介绍了gulp 静默失败 - 没有错误打印到控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 gulp 文件在标准 gulp 方法(如 gulp.src() 的路径不存在)上都没有发出任何错误,它们的处理程序也没有调用流错误.我已经包含了一个简单的文件,它静默失败,只打印开始..和完成..默认消息.

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

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:

这篇关于gulp 静默失败 - 没有错误打印到控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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