UNPKG

@mediamonks/commitlint-issue-reference

Version:

Ensures your commit messages always include the same issue key as in your branch name

48 lines (45 loc) 1.41 kB
/* eslint-disable no-console */ import chalk from 'chalk'; export function outputFoundTicketInBranch(ticket) { console.log(` Found ticket in branch: ${chalk.blue(ticket)} `); } export function outputNoTicketInBranch() { console.log(`No ticket found in branch name, skipping this check. `); } export function getErrorBlock() { return chalk.bold.whiteBright.bgRed(` Error `); } export function getActualHeader() { return chalk.bold.whiteBright.bgRedBright(` Actual: `); } export function getExpectedHeader() { return chalk.bold.whiteBright.bgGreenBright(` Expected: `); } export function outputAuthAddTicket(ticket, updatedMessage) { console.log(`No ticket found in commit message. Adding ticket ${chalk.blue(ticket)} to commit message. Updated commit message is: ${chalk.blue(updatedMessage)} `); } export function outputErrorInfo(missingTicket) { console.log(`Commit again with the issue reference ${chalk.blue(missingTicket)} included in the correct location. If the commit does not relate to this issue, use the ${chalk.blue(`--no-verify`)} flag to skip this check. `); } export function outputError(errorMessage, message, expectedMessage, missingTicket) { console.log(`${errorMessage} ${getActualHeader()} ${chalk.red(message)} ${expectedMessage ? ` ${getExpectedHeader()} ${chalk.green(expectedMessage)} ` : ''} `); outputErrorInfo(missingTicket); }