"use strict";

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

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

function _defineProperty2() {
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

  _defineProperty2 = function () {
    return data;
  };

  return data;
}

function _command() {
  const data = _interopRequireDefault(require("../cli/command"));

  _command = function () {
    return data;
  };

  return data;
}

class ExtensionCommand extends _command().default {
  constructor(props) {
    super();
    (0, _defineProperty2().default)(this, "name", '');
    (0, _defineProperty2().default)(this, "description", '');
    (0, _defineProperty2().default)(this, "opts", []);
    (0, _defineProperty2().default)(this, "private", false);
    (0, _defineProperty2().default)(this, "migration", false);
    (0, _defineProperty2().default)(this, "extension", true);
    (0, _defineProperty2().default)(this, "loader", true);
    this.name = props.name;
    this.description = props.description;
    this._action = props.action;
    this._report = props.report;
    this.opts = props.opts || [];
  } // A wrapper to make sure the action return a promise


  action(relevantArgs, opts) {
    return Promise.resolve(this._action(relevantArgs, opts));
  }

  report(data) {
    if (this._report && typeof this._report === 'function') {
      return this._report(data);
    }

    return super.report();
  }

}

exports.default = ExtensionCommand;