From 8ec7866980ed2a10e78edb5e47168f7fa9ce635a Mon Sep 17 00:00:00 2001 From: escapedcat Date: Wed, 29 Sep 2021 12:53:53 +0800 Subject: [PATCH] fix: integrate review feedback --- @commitlint/prompt/package.json | 4 ++-- @commitlint/prompt/src/index.ts | 16 ++++------------ .../prompt/src/inquirer/InputCustomPrompt.ts | 6 +++--- yarn.lock | 18 +++++++++--------- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/@commitlint/prompt/package.json b/@commitlint/prompt/package.json index a36727e79e..c421069da7 100644 --- a/@commitlint/prompt/package.json +++ b/@commitlint/prompt/package.json @@ -37,9 +37,9 @@ "node": ">=v12" }, "devDependencies": { - "@commitlint/config-angular": "^11.0.0", - "@commitlint/types": "^11.0.0", "@commitlint/utils": "^14.0.0", + "@commitlint/types": "^13.2.0", + "@commitlint/config-angular": "^13.2.0", "@types/inquirer": "^6.5.0", "inquirer": "^6.5.2", "commitizen": "^4.2.4" diff --git a/@commitlint/prompt/src/index.ts b/@commitlint/prompt/src/index.ts index ce0ef97724..ca85678b1a 100644 --- a/@commitlint/prompt/src/index.ts +++ b/@commitlint/prompt/src/index.ts @@ -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 { - const message = await input(cz.prompt); - commit(message); +export function prompter(cz: typeof inquirer, commit: Commit): void { + input(cz.prompt).then((message) => { + commit(message); + }); } diff --git a/@commitlint/prompt/src/inquirer/InputCustomPrompt.ts b/@commitlint/prompt/src/inquirer/InputCustomPrompt.ts index 779f2b1db1..036bb78cc3 100644 --- a/@commitlint/prompt/src/inquirer/InputCustomPrompt.ts +++ b/@commitlint/prompt/src/inquirer/InputCustomPrompt.ts @@ -1,10 +1,9 @@ /// -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; @@ -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); @@ -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) { diff --git a/yarn.lock b/yarn.lock index 9081ef26eb..800e6c5643 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1398,17 +1398,17 @@ resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@commitlint/config-angular-type-enum@^11.0.0": - version "11.0.0" - resolved "https://registry.npmjs.org/@commitlint/config-angular-type-enum/-/config-angular-type-enum-11.0.0.tgz#7a7f6982e45d3696d72eb343a5d1dc23b2f003e0" - integrity sha512-dSyxdkU36aEgDUWBSiM5lsZ/h2K7uCyKf+A5Sf3+Z5JhcLD9GzTo5W+c8KgwTBdL39dkL7sN+EVgsXNjW99pJg== +"@commitlint/config-angular-type-enum@^13.2.0": + version "13.2.0" + resolved "https://registry.npmjs.org/@commitlint/config-angular-type-enum/-/config-angular-type-enum-13.2.0.tgz#e3f9b8a07118ed8e060b0b1d04a549f74957634d" + integrity sha512-HSP9lzCoHC9+bjJquvByiSUpo0GbAipbjcT6l3Jl6XOzkCjhnUkYcQ2b/O5nXv3mf8Vv/n5k2Sk4nbCYEVpSGQ== -"@commitlint/config-angular@^11.0.0": - version "11.0.0" - resolved "https://registry.npmjs.org/@commitlint/config-angular/-/config-angular-11.0.0.tgz#c1cc1dd902a4b9d2a5c072ff38e3ace9be7138e0" - integrity sha512-H8QSEOmfRsPW0Iehid5fY7NZ2HXmyKC6Q83MLFf9KRnmCcbgJtH+faECtqlvPntayO3CYbA4UenIerOaQ0vOAg== +"@commitlint/config-angular@^13.2.0": + version "13.2.0" + resolved "https://registry.npmjs.org/@commitlint/config-angular/-/config-angular-13.2.0.tgz#78c62551279bdf7ed3a9bf993751f346c42b2944" + integrity sha512-mfytI8ZrPt7kuxjZo0ZfFw0bg1zEa2kI6/prVaYJ0FJgOE8EP1Co9Y4DJZEegohfYFeRcFK3radog7WOr2pzdw== dependencies: - "@commitlint/config-angular-type-enum" "^11.0.0" + "@commitlint/config-angular-type-enum" "^13.2.0" "@endemolshinegroup/cosmiconfig-typescript-loader@^3.0.2": version "3.0.2"