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 6f8575a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
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 6f8575a

Please sign in to comment.