'use strict';

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

var _fsExtra;

function _load_fsExtra() {
  return _fsExtra = _interopRequireDefault(require('fs-extra'));
}

var _path;

function _load_path() {
  return _path = _interopRequireWildcard(require('path'));
}

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

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

function rmDir(path) {
  if ((_fsExtra || _load_fsExtra()).default.existsSync(path)) {
    (_fsExtra || _load_fsExtra()).default.readdirSync(path).forEach(function (file) {
      var curPath = (_path || _load_path()).join(path, file);
      if ((_fsExtra || _load_fsExtra()).default.lstatSync(curPath).isDirectory()) {
        rmDir(curPath);
      } else {
        (_fsExtra || _load_fsExtra()).default.unlinkSync(curPath);
      }
    });
    (_fsExtra || _load_fsExtra()).default.rmdirSync(path);
  }
}