"use strict";

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

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.pathJoinLinux = pathJoinLinux;
exports.pathNormalizeToLinux = pathNormalizeToLinux;
exports.pathRelativeLinux = pathRelativeLinux;
exports.pathResolveToLinux = pathResolveToLinux;
exports.getPathRelativeRegardlessCWD = getPathRelativeRegardlessCWD;

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

  _path = function () {
    return data;
  };

  return data;
}

function _normalizePath() {
  const data = _interopRequireDefault(require("normalize-path"));

  _normalizePath = function () {
    return data;
  };

  return data;
}

function pathJoinLinux(...paths) {
  return (0, _normalizePath().default)(_path().default.join(...paths));
}

function pathNormalizeToLinux(pathToNormalize) {
  return pathToNormalize ? (0, _normalizePath().default)(pathToNormalize) : pathToNormalize;
}

function pathRelativeLinux(from, to) {
  return (0, _normalizePath().default)(_path().default.relative(from, to));
}

function pathResolveToLinux(arr) {
  return (0, _normalizePath().default)(_path().default.resolve(arr.join(',')));
}
/**
 * path.resolve uses current working dir.
 * sometimes the cwd is not important. a user may running bit command from an inner dir.
 */


function getPathRelativeRegardlessCWD(from, to) {
  const fromLinux = pathNormalizeToLinux(from);
  const toLinux = pathNormalizeToLinux(to); // change them to absolute so path.relative won't consider the cwd

  return pathRelativeLinux(`/${fromLinux}`, `/${toLinux}`);
}