error-handling - gulp-tasks加载的任务失败后,错误退出

标签 error-handling gulp

我正在与magento2-frontools合作,并尝试解决此问题:

https://github.com/SnowdogApps/magento2-frontools/issues/231

问题是,如果出现错误,gulp styles应该具有非零的退出代码,但是它会以0退出。

gulp文件如下所示:

// Tasks loading
require('gulp-task-loader')({
  dir    : 'task',
  plugins: plugins,
  configs: config
});

而styles.js任务是这样的:
  'use strict';
  module.exports = function() { // eslint-disable-line func-names
    // Global variables
    const gulp    = this.gulp,
      plugins = this.opts.plugins,
      config  = this.opts.configs,
      themes  = plugins.getThemes(),
      streams = plugins.mergeStream();

    // Generate all necessary symlinks before styles compilation, but ony if not a part of tasks pipeline
    if (!plugins.util.env.pipeline) {
      plugins.runSequence('inheritance');
    }

    // Loop through themes to compile scss or less depending on your config.json
    themes.forEach(name => {
      streams.add(require('../helper/scss')(gulp, plugins, config, name));
    });

    return streams;
  };

(都可以是found on GitHub)

如果看过this approach来解决问题:
.once("error", function () {
   this.once("finish", () => process.exit(1));
})

但是我可以在哪里添加该代码?

最佳答案

仅需使用--ci标志。

关于error-handling - gulp-tasks加载的任务失败后,错误退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45006766/

相关文章:

javascript - 如何使用 gulp 将已安装 Bower 包的链接注入(inject) html 文件

python - discord.py 对 cog 中每个命令的错误处理

php - 出色地处理从代码中不同位置浮出的非对象错误的属性

java - 如何使用 Struts 2 框架构建自定义 JSON 错误响应

gulp - 使用 Webstorm 时 Watchify 不更新

javascript - 任务从未定义: browserSync.重新加载

swift - “ fatal error :在展开可选值时意外发现nil”是什么意思?

php - PHP Whoops错误句柄清除缓冲区

javascript - 在 gulp 4.0 中使用串行和并行任务

javascript - Full Gulp Istanbul 尔报道报告