question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[@commitlint/prompt] get error use '@commitlint/prompt' with commitizen

See original GitHub issue

As title.

Expected Behavior

Current Behavior

i got Could not find prompter method in the provided adapter module: @commitlint/prompt

Affected packages

  • prompt

Possible Solution

Maybe this code as below at commitizen/adapter.js, got a error:

function getPrompter(adapterPath) {
  cov_8emx7ww64.f[7]++;
  // Resolve the adapter path
  let resolvedAdapterPath = (cov_8emx7ww64.s[25]++, resolveAdapterPath(adapterPath)); // Load the adapter

  let adapter = (cov_8emx7ww64.s[26]++, require(resolvedAdapterPath));
  /* istanbul ignore next */

  if (adapter && adapter.prompter && (0, _util.isFunction)(adapter.prompter)) {
    return adapter.prompter;
  } else if (adapter && adapter.default && adapter.default.prompter && (0, _util.isFunction)(adapter.default.prompter)) {
    return adapter.default.prompter;
  } else {
    throw new Error(`Could not find prompter method in the provided adapter module: ${adapterPath}`);
  }
}

Steps to Reproduce (for bugs)

  1. First step
  2. Second step
```js module.exports = { extends: ['@commitlint/config-conventional'] } ```

and package.json

{
  "scripts": {
    "commit": "git-cz"
  },
  "config": {
    "commitizen": {
      "path": "@commitlint/prompt"
    }
  }
}

Context

Your Environment

Executable Version
commitlint --version 12.0.1
git --version 2.25.1
node --version 12.16.1
commitizen --version 4.2.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tal-rofecommented, Apr 24, 2022

@tal-rofe would you mind creating a new issue and maybe a repo for reproduction? Thanks

Hi, I opened the issue in commitizen repo page as it is more related with their code

2reactions
armano2commented, Mar 5, 2021

@escapedcat @a-pavlov-parc i did some digging and there seem to be an issue in commitizen


v11: code was transpiled with babel and async functions where converted to functions with regenerator v12: code is compiled with typescript and there is no need anymore to do this transformation


https://github.com/commitizen/cz-cli/blob/ba7eeb67c4d3347cc2369ff6538d9d97761cedc8/src/commitizen/adapter.js#L150-L153

function getPrompter (adapterPath) {
  // Resolve the adapter path
  let resolvedAdapterPath = resolveAdapterPath(adapterPath);

  // Load the adapter
  let adapter = require(resolvedAdapterPath);

  /* istanbul ignore next */
  if (adapter && adapter.prompter && isFunction(adapter.prompter)) {
     return adapter.prompter;
  } else if (adapter && adapter.default && adapter.default.prompter && isFunction(adapter.default.prompter)) {
     return adapter.default.prompter;
  } else {
    throw new Error(`Could not find prompter method in the provided adapter module: ${adapterPath}`);
  }
}

adapter.prompter is a async function but isFunction returns false

function isFunction (functionToCheck) {
  if (typeof functionToCheck === "undefined")
  {
    return false;
  } else if (functionToCheck === null) {
    return false;
  } else {
    var getType = {};
    return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  }
}
Object.prototype.toString.call(async function () {}) // [object AsyncFunction]
Object.prototype.toString.call(function () {}) // [object Function]

this implementation is not correct as it should be

function isFunction (functionToCheck) {
   return typeof functionToCheck === 'function'
}

this issue should be reported to commitizen but as “workaround” we could take this

https://github.com/conventional-changelog/commitlint/blob/6a48e44dbc803bf49b1f9253e650ca1184421914/%40commitlint/prompt/src/index.ts#L14-L17

and replace it with

export function prompter(_: unknown, commit: Commit): void {
	input(vorpal).then((message) => {
		commit(message);
	});
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

@commitlint/prompt | Yarn - Package Manager
This is the library and commitizen adapter version of commitlint prompt. A ready-to-use cli version is available at @commitlint/prompt-cli. Learn how to use...
Read more >
commitlint - Lint commit messages
commitlint helps your team adhere to a commit convention. By supporting npm-installed configurations it makes sharing of commit conventions easy. Getting ...
Read more >
commitizen - npm
Start using commitizen in your project by running `npm i commitizen`. There are 669 other projects in the npm registry using commitizen.
Read more >
Enhance your commits with Git hooks! • Delicious Insights
Note: you don't have to work with JavaScript to use npm and husky; ... @commitlint/prompt-cli ), but I prefer git commitizen that lets...
Read more >
commitlint - Bountysource
It doesn't catch anything and shows no errors found ... The current implementation of @commitlint/prompt is tied to vorpal .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found