Nicely throwing an error in gulp task

前端 未结 1 877
不思量自难忘°
不思量自难忘° 2021-01-17 18:57

I am creating a gulp task which might fail under certain circumstances.

gulp.task(\'favicon\', function () {
  try {
    require(\'child_process\').execSync(         


        
相关标签:
1条回答
  • 2021-01-17 19:29

    From what I've seen its not great to throw an error from gulp. But I found this blog entry that I used to work for me.

    http://gotofritz.net/blog/geekery/how-to-generate-error-in-gulp-task/

    Edit: gulp-util has been deprecated. Instead, use the plugin-error package.

    My Example:

    var gulp = require('gulp');
    var error = require('plugin-error');
    gulp.task('deploy', function(cb) {
      if(typeof(specialId) === 'undefined') {
        var err = new PluginError({
          plugin: 'deploy',
          message: 'specialId is empty.'
        });
      }
    }
    
    0 讨论(0)
提交回复
热议问题