import { yellow } from "picocolors"; import { CommitBuilder } from "~/modules/commit/builder/CommitBuilder"; import { CommitBody } from "~/modules/commit/types"; import { BaseConventionalHandler } from "../BaseConventionalHandler"; export const ABORT_MESSAGE = `${yellow("✖")} Commit body aborted!`; export class ConventionalBodyHandler extends BaseConventionalHandler { protected async processInput(commitBuilder: CommitBuilder): Promise { const commitBody = await this.selectCommitBody(); commitBuilder.withBody(commitBody); } private async selectCommitBody(): Promise { let bodyLines: string[] = []; const hasBody = await this.promptManager.confirm({ defaultValue: false, message: "Does this commit have a body?", abortMessage: ABORT_MESSAGE, }); if (hasBody) { bodyLines = await this.promptManager.multiText({ text: { message: "Please enter a body line:", abortMessage: ABORT_MESSAGE, }, confirm: { message: "Do you need another body line?", abortMessage: ABORT_MESSAGE, }, }); } return { message: bodyLines.join("\n"), }; } }