(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('util'), require('fs'), require('child_process')) :
  typeof define === 'function' && define.amd ? define(['exports', 'util', 'fs', 'child_process'], factory) :
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.git = {}, global.util, global.fs, global.child_process));
})(this, (function (exports, util, fs, child_process) { 'use strict';

  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

  var util__default = /*#__PURE__*/_interopDefaultLegacy(util);
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
  var child_process__default = /*#__PURE__*/_interopDefaultLegacy(child_process);

  const exec = util__default["default"].promisify(child_process__default["default"].exec);
  util__default["default"].promisify(child_process__default["default"].execFile);
  util__default["default"].promisify(child_process__default["default"].spawn);
  const stat = util__default["default"].promisify(fs__default["default"].stat);
  const readFile = util__default["default"].promisify(fs__default["default"].readFile);

  const EDIT_MSG_FILE = ".git/COMMIT_EDITMSG";
  async function getCommitMsg() {
    try {
      const gitLog = await exec("git log -1 --pretty=%B");
      return gitLog.stdout;
    } catch {
    }
    if (await stat(EDIT_MSG_FILE))
      return (await readFile(EDIT_MSG_FILE)).toString();
    throw new Error("not found");
  }

  exports.getCommitMsg = getCommitMsg;

  Object.defineProperty(exports, '__esModule', { value: true });

}));
