"use strict";

var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");

require("core-js/modules/es.array.iterator");

var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");

_Object$defineProperty(exports, "__esModule", {
  value: true
});

exports.default = void 0;

var _lastIndexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/last-index-of"));

var _events = _interopRequireDefault(require("events"));

var _chalk = _interopRequireDefault(require("chalk"));

var _header = _interopRequireDefault(require("./header"));

const filteredPlugins = ['sequence', 'find', 'remove,']; //const filteredPlugins = []

const isNotFiletered = pluginName => (0, _lastIndexOf.default)(filteredPlugins).call(filteredPlugins, pluginName) === -1;

var _default = taskName => {
  const emitter = new _events.default();
  emitter.on('start', pluginName => {
    if (isNotFiletered(pluginName)) {
      (0, _header.default)(pluginName);
    }
  });
  emitter.on('message', (pluginName, ...message) => {
    console.log(_chalk.default.gray(pluginName), ...message);
  });
  emitter.on('warning', (pluginName, message) => {
    console.log(_chalk.default.yellow(pluginName), message);
  });
  emitter.on('file', (pluginName, file) => {});
  emitter.on('done', pluginName => {
    if (isNotFiletered(pluginName)) {
      console.log(_chalk.default.grey(pluginName + ' done'));
    }
  });
  emitter.on('error', (pluginName, error) => {
    if (isNotFiletered(pluginName)) {
      console.log(_chalk.default.red('Error: ' + pluginName), error || '');
    }

    process.exit(1);
  });
  return emitter;
};

exports.default = _default;
module.exports = exports.default;