UNPKG

@commitlint/prompt

Version:

commitizen prompt using commitlint.config.js

34 lines 1.05 kB
import chalk from "chalk"; /** * Get formatted commit message * @param input object containing structured results * @param debug show debug information in commit message * @return formatted debug message */ export default function format(input, debug = false) { const defaultInput = { type: undefined, scope: undefined, subject: undefined, body: undefined, footer: undefined, ...input, }; const results = debug ? Object.entries(defaultInput).reduce((registry, [name, value]) => { registry[name] = value === undefined ? chalk.grey(`<${name}>`) : chalk.bold(value); return registry; }, {}) : defaultInput; // Return formatted string const { type, scope, subject, body, footer } = results; return [ `${type || ""}${scope ? `(${scope})` : ""}${type || scope ? ":" : ""} ${subject || ""}`, body, footer, ] .filter(Boolean) .join("\n"); } //# sourceMappingURL=format.js.map