diff --git a/src/index.ts b/src/index.ts index 079b856a..3cc7bfc9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,40 +8,39 @@ import { formatHeader, formatIssues, formatBreakingChange } from './pipes/commit import { getQuestions } from './utils/questions'; import type { ICommitFunc } from './interfaces/commit'; -const prompter = (cz: Inquirer, commit: ICommitFunc) => { +const prompter = async (cz: Inquirer, commit: ICommitFunc) => { cz.prompt.registerPrompt('autocomplete', InquirerAutoComplete); cz.prompt.registerPrompt('maxlength-input', InquirerMaxLength); - // ! - There is an open issue for using "then" rather than "await": https://github.com/commitizen/cz-cli/issues/926 - getConfiguration().then(async (configuration) => { - const wrapOptions = { - indent: '', - trim: true, - width: configuration.maxCommitLineWidth, - }; - - const questions = await getQuestions(configuration); - const answers = await cz.prompt(questions); - - commit( - [ - formatHeader( - configuration.headerFormat, - answers.type.type, - answers.scope, - answers.type.emoji, - answers.ticket_id, - answers.subject, - ), - wrap(answers.body || '', wrapOptions), - wrap(formatBreakingChange(answers.breakingBody) || '', wrapOptions), - formatIssues(answers.issues), - ] - .filter(Boolean) - .join('\n\n') - .trim(), - ); - }); + const configuration = await getConfiguration(); + + const wrapOptions = { + indent: '', + trim: true, + width: configuration.maxCommitLineWidth, + }; + + const questions = await getQuestions(configuration); + const answers = await cz.prompt(questions); + + commit( + [ + formatHeader( + configuration.headerFormat, + answers.type.type, + answers.scope, + answers.type.emoji, + answers.ticket_id, + answers.subject, + ), + wrap(answers.body || '', wrapOptions), + wrap(formatBreakingChange(answers.breakingBody) || '', wrapOptions), + formatIssues(answers.issues), + ] + .filter(Boolean) + .join('\n\n') + .trim(), + ); }; const InqObj = { prompter };