Skip to content

Commit

Permalink
fix: integrate review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
escapedcat committed Sep 29, 2021
1 parent 523865a commit d1bdcc4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion @commitlint/prompt/package.json
Expand Up @@ -37,13 +37,13 @@
},
"devDependencies": {
"@commitlint/utils": "^13.2.0",
"@commitlint/types": "^13.2.0",
"@commitlint/config-angular": "^13.2.0",
"@types/inquirer": "^6.5.0",
"commitizen": "^4.2.4"
},
"dependencies": {
"@commitlint/load": "^13.2.0",
"@commitlint/types": "^13.2.0",
"chalk": "^4.0.0",
"lodash": "^4.17.19",
"inquirer": "^6.5.2"
Expand Down
16 changes: 4 additions & 12 deletions @commitlint/prompt/src/index.ts
Expand Up @@ -3,16 +3,8 @@ import {input} from './input';

type Commit = (input: string) => void;

/**
* Entry point for commitizen
* @param cz inquirer instance passed by commitizen
* @param commit callback to execute with complete commit message
* @return {void}
*/
export async function prompter(
cz: typeof inquirer,
commit: Commit
): Promise<void> {
const message = await input(cz.prompt);
commit(message);
export function prompter(cz: typeof inquirer, commit: Commit): void {
input(cz.prompt).then((message) => {
commit(message);
});
}
6 changes: 3 additions & 3 deletions @commitlint/prompt/src/inquirer/InputCustomPrompt.ts
@@ -1,10 +1,9 @@
/// <reference path="./inquirer.d.ts" />
import {Interface as ReadlineInterface, Key} from 'readline';

import chalk from 'chalk';
import inquirer from 'inquirer';
import InputPrompt from 'inquirer/lib/prompts/input';
import observe from 'inquirer/lib/utils/events';
import {Interface as ReadlineInterface, Key} from 'readline';
import type {Subscription} from 'rxjs/internal/Subscription';

import Answers = inquirer.Answers;
Expand Down Expand Up @@ -86,7 +85,6 @@ export default class InputCustomPrompt<
render(error?: string): void {
const answered = this.status === 'answered';

let bottomContent = '';
let message = this.getQuestion();
const length = this.measureInput(this.rl.line);

Expand All @@ -96,6 +94,8 @@ export default class InputCustomPrompt<
message += this.opt.transformer(this.rl.line, this.answers, {});
}

let bottomContent = '';

if (error) {
bottomContent = chalk.red('>> ') + error;
} else if (!answered) {
Expand Down

0 comments on commit d1bdcc4

Please sign in to comment.