Skip to content

"Could not find prompter method in the provided adapter module: dist/index.js" #926

Description

@tal-rofe

I created my own adapter for commitizen. At first, I built the adapter using TSC.
The problem is that I export an async function:

import{Inquirer}from'inquirer';importInquirerAutoCompletefrom'inquirer-autocomplete-prompt';importInquirerMaxLengthfrom'inquirer-maxlength-input-prompt';importwrapfrom'word-wrap';import{getConfiguration}from'./utils/configuration';import{formatHeader,formatIssues,formatBreakingChange}from'./pipes/commit-format';import{getQuestions}from'./utils/questions';import{ICommitFunc}from'./interfaces/commit';constprompter=async(cz: Inquirer,commit: ICommitFunc)=>{cz.prompt.registerPrompt('autocomplete',InquirerAutoComplete);cz.prompt.registerPrompt('maxlength-input',InquirerMaxLength);constconfiguration=awaitgetConfiguration();constwrapOptions={indent: '',trim: true,width: configuration.maxCommitLineWidth,};constquestions=awaitgetQuestions(configuration);constanswers=awaitcz.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(),);};constInqObj={ prompter };exportdefaultInqObj;

But when I try to apply this adapter with commitizen I got the error in the title.
When I transformed my exported function to non-async, but using "().then()" it was resolved

The reason is, when exporting such thing, its type is: [object AsyncFunction]
However, commitizen will emit error.
Because: https://github.com/commitizen/cz-cli/blob/master/src/common/util.js
line 41: return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
This should be:

return functionToCheck && (getType.toString.call(functionToCheck) === '[object Function]' || getType.toString.call(functionToCheck) === '[object AsyncFunction]');

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions