Alex
Alex

Reputation: 35028

Exit with error after a task loaded by gulp-tasks failed

I am working with magento2-frontools and try to solve this issue:

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

The problem is, that gulp styles should have a non-zero exit code in case of errors, but it exits with 0.

The gulp file looks like this:

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

And the styles.js task like this:

  '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;
  };

(it can all be found on GitHub)

If have seen this approach to solve the problem:

.once("error", function () {
   this.once("finish", () => process.exit(1));
})

But where can I add that code?

Upvotes: 0

Views: 451

Answers (1)

Alex
Alex

Reputation: 35028

Just the --ci flag has to be used.

Upvotes: 1

Related Questions