UNPKG

1.28 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6const chalk_1 = __importDefault(require("chalk"));
7/**
8 * Get formatted commit message
9 * @param input object containing structured results
10 * @param debug show debug information in commit message
11 * @return formatted debug message
12 */
13function format(input, debug = false) {
14 const defaultInput = Object.assign({ type: undefined, scope: undefined, subject: undefined, body: undefined, footer: undefined }, input);
15 const results = debug
16 ? Object.entries(defaultInput).reduce((registry, [name, value]) => {
17 registry[name] =
18 value === undefined ? chalk_1.default.grey(`<${name}>`) : chalk_1.default.bold(value);
19 return registry;
20 }, {})
21 : defaultInput;
22 // Return formatted string
23 const { type, scope, subject, body, footer } = results;
24 return [
25 `${type || ''}${scope ? `(${scope})` : ''}${type || scope ? ':' : ''} ${subject || ''}`,
26 body,
27 footer,
28 ]
29 .filter(Boolean)
30 .join('\n');
31}
32exports.default = format;
33//# sourceMappingURL=format.js.map
\No newline at end of file