"use strict";

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

function _react() {
  const data = _interopRequireDefault(require("react"));

  _react = function _react() {
    return data;
  };

  return data;
}

function _rimraf() {
  const data = _interopRequireDefault(require("rimraf"));

  _rimraf = function _rimraf() {
    return data;
  };

  return data;
}

function _ora() {
  const data = _interopRequireDefault(require("ora"));

  _ora = function _ora() {
    return data;
  };

  return data;
}

function _chalk() {
  const data = _interopRequireDefault(require("chalk"));

  _chalk = function _chalk() {
    return data;
  };

  return data;
}

var _download = require("./download");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * 清理 git 缓存目录
 * @param args
 * @param param1
 */
function clearGitCache(args, {
  log
}) {
  const spinner = (0, _ora().default)();
  const blocksTempPath = (0, _download.makeSureMaterialsTempPathExist)(args.dryRun);
  const info = `🗑  start clear: ${_chalk().default.yellow(blocksTempPath)}`;
  spinner.start(info);

  try {
    _rimraf().default.sync(blocksTempPath);

    spinner.succeed();
  } catch (error) {
    log.error(error);
    spinner.stop();
  }

  return `🗑  start clear: ${blocksTempPath}`;
}