get-edit-commit.js 967 B

123456789101112131415161718192021
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.getEditCommit = void 0;
  7. const top_level_1 = __importDefault(require("@commitlint/top-level"));
  8. const fs_extra_1 = __importDefault(require("fs-extra"));
  9. const get_edit_file_path_1 = require("./get-edit-file-path");
  10. // Get recently edited commit message
  11. async function getEditCommit(cwd, edit) {
  12. const top = await (0, top_level_1.default)(cwd);
  13. if (typeof top !== 'string') {
  14. throw new TypeError(`Could not find git root from ${cwd}`);
  15. }
  16. const editFilePath = await (0, get_edit_file_path_1.getEditFilePath)(top, edit);
  17. const editFile = await fs_extra_1.default.readFile(editFilePath);
  18. return [`${editFile.toString('utf-8')}\n`];
  19. }
  20. exports.getEditCommit = getEditCommit;
  21. //# sourceMappingURL=get-edit-commit.js.map