"use strict";

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

require("core-js/modules/es.promise");

var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");

_Object$defineProperty(exports, "__esModule", {
  value: true
});

exports.default = void 0;

var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));

var _plugin = _interopRequireDefault(require("@start/plugin"));

var _clean = _interopRequireDefault(require("@lerna/clean"));

var _isWorkspace = _interopRequireDefault(require("../utils/isWorkspace"));

var _default = () => (0, _plugin.default)('LERNA CLEAN', ({
  reporter
}) =>
/*#__PURE__*/
(0, _asyncToGenerator2.default)(function* () {
  const exists = yield (0, _isWorkspace.default)();

  if (exists) {
    try {
      yield (0, _clean.default)({
        yes: true
      });
      return _promise.default.resolve();
    } catch (e) {
      return _promise.default.reject(e);
    }
  } else {
    reporter.emit('message', 'Repo is not monorepo, skipping clean packages');
    return _promise.default.resolve();
  }
}));

exports.default = _default;
module.exports = exports.default;