"use strict";

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

var _child_process = require("child_process");

var _default = (type = 'git', cwd = process.cwd()) => {
  let results;

  if (type === 'git') {
    results = (0, _child_process.spawnSync)('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
      encoding: 'utf8',
      cwd
    });
  } else if (type === 'hg') {
    results = (0, _child_process.spawnSync)('hg', ['identify', '-b'], {
      encoding: 'utf8',
      cwd
    });
  }

  let [currentBranch] = results && results.output ? results.output.filter(d => d) : [''];
  return currentBranch.replace(/(\r\n|\n|\r)/gm, '');
};

exports.default = _default;