-
Notifications
You must be signed in to change notification settings - Fork 962
Expand file tree
/
Copy pathProcess.ts
More file actions
39 lines (36 loc) · 1.1 KB
/
Process.ts
File metadata and controls
39 lines (36 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { QualifiedRules, UserPromptConfig } from "@commitlint/types";
import type { Answers, DistinctQuestion } from "inquirer";
import {
combineCommitMessage as combineBody,
getQuestions as getBodyQuestions,
} from "./SectionBody.js";
import {
combineCommitMessage as combineFooter,
getQuestions as getFooterQuestions,
} from "./SectionFooter.js";
import {
combineCommitMessage as combineHeader,
getQuestions as getHeaderQuestions,
} from "./SectionHeader.js";
import { setPromptConfig } from "./store/prompts.js";
import { setRules } from "./store/rules.js";
export default async function (
rules: QualifiedRules,
prompts: UserPromptConfig,
inquirer: {
prompt(questions: DistinctQuestion[]): Promise<Answers>;
},
): Promise<string> {
setRules(rules);
setPromptConfig(prompts);
const questions = [
...getHeaderQuestions(),
...getBodyQuestions(),
...getFooterQuestions(),
];
const answers = await inquirer.prompt(questions);
const header = combineHeader(answers);
const body = combineBody(answers);
const footer = combineFooter(answers);
return [header, body, footer].filter(Boolean).join("\n");
}