"use strict";

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

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.composeComponentPath = composeComponentPath;
exports.composeDependencyPath = composeDependencyPath;
exports.composeDependencyPathForIsolated = composeDependencyPathForIsolated;

function _path() {
  const data = _interopRequireDefault(require("path"));

  _path = function () {
    return data;
  };

  return data;
}

function _stringFormat() {
  const data = _interopRequireDefault(require("string-format"));

  _stringFormat = function () {
    return data;
  };

  return data;
}

function _constants() {
  const data = require("../../constants");

  _constants = function () {
    return data;
  };

  return data;
}

function _bitId() {
  const data = _interopRequireDefault(require("../../bit-id/bit-id"));

  _bitId = function () {
    return data;
  };

  return data;
}

function composeComponentPath(bitId, componentsDefaultDirectory = _constants().DEFAULT_COMPONENTS_DIR_PATH) {
  return (0, _stringFormat().default)(componentsDefaultDirectory, {
    name: bitId.name,
    scope: bitId.scope
  });
}

function composeDependencyPath(bitId, dependenciesDir = _constants().DEFAULT_DEPENDENCIES_DIR_PATH) {
  return _path().default.join(dependenciesDir, bitId.toFullPath());
}

function composeDependencyPathForIsolated(bitId, dependenciesDir = _constants().DEFAULT_DEPENDENCIES_DIR_PATH) {
  const getIdPath = () => {
    try {
      return bitId.toFullPath();
    } catch (err) {
      return bitId.name;
    }
  };

  return _path().default.join(dependenciesDir, getIdPath());
}