"use strict";

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

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

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

exports.default = void 0;

var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));

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

var _plugin = _interopRequireDefault(require("@start/plugin"));

var _default = (enabled, func, params, title) => (0, _plugin.default)(`OPTIONAL STEP: ${title}`, pluginProps => /*#__PURE__*/function () {
  var _ref = (0, _asyncToGenerator2.default)(function* (props) {
    const {
      reporter
    } = pluginProps;

    if (enabled) {
      reporter.emit('message', 'Running optional step');
      yield func(params)(reporter)(props);
      return _promise.default.resolve();
    }

    reporter.emit('message', `Skipping optional step: ${title}`);
  });

  return function (_x) {
    return _ref.apply(this, arguments);
  };
}());

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