pivotal-flow
Version:
🔀 A command-line tool that helps you manage & automate your workflow to use with PivotalTracker.
44 lines (38 loc) • 2.15 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
const regex_1 = require("../../regex");
const fs_1 = require("../../utils/fs");
const console_1 = require("../../utils/console");
function commitMsgHook(commitMessageFilename) {
return __awaiter(this, void 0, void 0, function* () {
const commitMessage = yield fs_1.readFile(commitMessageFilename, { encoding: 'utf8' });
if (!regex_1.PIVOTAL_ID_IN_STRING.test(commitMessage)) {
console_1.warning(`
${chalk_1.default.inverse('[WARNING]')} A Pivotal Story ID is missing from your commit message! 🦄
Your commit message:
${chalk_1.default.white.bold(commitMessage)}
---
If this is your first time contributing to this repository - welcome!
Please refer to: ${chalk_1.default.underline('https://github.com/ClearTax/pivotal-flow#usage')} to get started.
${chalk_1.default.dim(`
Without the Pivotal Story ID in your commit message, you would lose out on automatic updates to Pivotal stories when pushing your branch to the remote.
Use '${chalk_1.default.underline('pivotal-flow hook prepare-commit-msg')}' to automate this for you.
`)}`);
throw 'commit-msg: failed to find pivotal id in commit message';
}
});
}
exports.default = commitMsgHook;