"use strict";

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

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

function _bluebird() {
  const data = require("bluebird");

  _bluebird = function () {
    return data;
  };

  return data;
}

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

  _fsExtra = function () {
    return data;
  };

  return data;
}

function _removeFilesAndEmptyDirsRecursively() {
  const data = _interopRequireDefault(require("../../../utils/fs/remove-files-and-empty-dirs-recursively"));

  _removeFilesAndEmptyDirsRecursively = function () {
    return data;
  };

  return data;
}

class RemovePath {
  constructor(path, removeItsDirIfEmpty = false) {
    this.path = path;
    this.removeItsDirIfEmpty = removeItsDirIfEmpty;
  }

  persistToFS() {
    var _this = this;

    return (0, _bluebird().coroutine)(function* () {
      if (_this.removeItsDirIfEmpty) {
        return (0, _removeFilesAndEmptyDirsRecursively().default)([_this.path]);
      }

      return _fsExtra().default.remove(_this.path);
    })();
  }

}

exports.default = RemovePath;