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

Function input

@commitlint/prompt/src/input.ts:17–49  ·  view source on GitHub ↗
(prompter: PromptModule)

Source from the content-addressed store, hash-verified

15 * @return commit message
16 */
17export async function input(prompter: PromptModule): Promise<string> {
18 const { rules } = await load();
19 const parts = ["type", "scope", "subject", "body", "footer"] as const;
20 const headerParts = ["type", "scope", "subject"];
21
22 const headerLengthRule = getRules("header", rules).find(getHasName("max-length"));
23 const maxLength = getMaxLength(headerLengthRule);
24
25 try {
26 const questions: DistinctQuestion<Result>[] = [];
27 prompter.registerPrompt("input-custom", InputCustomPrompt);
28
29 for (const input of parts) {
30 const inputSetting: InputSetting = settings[input];
31 const inputRules = getRules(input, rules);
32 if (headerParts.includes(input) && maxLength < Infinity) {
33 inputSetting.header = {
34 length: maxLength,
35 };
36 }
37 const question = getPrompt(input, inputRules, inputSetting);
38 if (question) {
39 questions.push(question);
40 }
41 }
42
43 const results = await prompter<Result>(questions);
44 return format(results);
45 } catch (err) {
46 console.error(err);
47 return "";
48 }
49}

Callers 2

input.test.tsFile · 0.85
prompterFunction · 0.85

Calls 6

loadFunction · 0.85
getRulesFunction · 0.85
getHasNameFunction · 0.85
getPromptFunction · 0.85
getMaxLengthFunction · 0.50
formatFunction · 0.50

Tested by

no test coverage detected