MCPcopy Create free account
hub / github.com/conventional-changelog/commitlint / formatInput

Function formatInput

@commitlint/format/src/format.ts:29–53  ·  view source on GitHub ↗
(result: FormattableResult & WithInput, options: FormatOptions = {})

Source from the content-addressed store, hash-verified

27}
28
29function formatInput(result: FormattableResult & WithInput, options: FormatOptions = {}): string[] {
30 const { color: enabled = true, legacyOutput = false } = options;
31 const { errors = [], warnings = [], input = "" } = result;
32
33 if (!input) {
34 return [""];
35 }
36
37 const sign = "⧗";
38 const decoration = enabled ? pc.gray(sign) : sign;
39
40 const decoratedInput = enabled ? pc.bold(input) : input;
41 const hasProblems = errors.length > 0 || warnings.length > 0;
42
43 if (!(options.verbose || hasProblems)) {
44 return [];
45 }
46
47 if (legacyOutput) {
48 // legacy: single line with 'input: ' prefix, no extra newlines or dashes
49 return [`${decoration} input: ${decoratedInput}`];
50 }
51
52 return [`${decoration} --- input ---\n${decoratedInput}`];
53}
54
55export function formatResult(
56 result: FormattableResult = {},

Callers 1

fiFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected