"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 _chalk() {
  const data = _interopRequireDefault(require("chalk"));

  _chalk = function () {
    return data;
  };

  return data;
}

function _fsExtra() {
  const data = _interopRequireDefault(require("fs-extra"));

  _fsExtra = function () {
    return data;
  };

  return data;
}

function _v8CompileCache() {
  const data = require("v8-compile-cache");

  _v8CompileCache = function () {
    return data;
  };

  return data;
}

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

  _command = function () {
    return data;
  };

  return data;
}

// it's a hack, but I didn't find a better way to access the getCacheDir() function
const {
  BASE_DOCS_DOMAIN
} = require('../../../constants');

class ClearCache extends _command().default {
  constructor(...args) {
    super(...args);
    (0, _defineProperty2().default)(this, "name", 'clear-cache');
    (0, _defineProperty2().default)(this, "description", `clears bit's cache from current working machine\n  https://${BASE_DOCS_DOMAIN}/docs/cli-clear-cache.html`);
    (0, _defineProperty2().default)(this, "alias", 'cc');
    (0, _defineProperty2().default)(this, "opts", []);
    (0, _defineProperty2().default)(this, "loader", false);
  }

  action() {
    const cacheDir = _v8CompileCache().__TEST__.getCacheDir();

    _fsExtra().default.removeSync(cacheDir);

    return Promise.resolve();
  }

  report() {
    return _chalk().default.green('cache cleared');
  }

}

exports.default = ClearCache;