refactor(v2): Switch from inquirer to prompts (#4091)

Signed-off-by: Reece Dunham <me@rdil.rocks>
This commit is contained in:
Reece Dunham 2021-01-27 10:53:43 -05:00 committed by GitHub
parent b49ff32417
commit 95f81d2a44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 23 deletions

View file

@ -77,7 +77,6 @@
"html-tags": "^3.1.0",
"html-webpack-plugin": "^4.5.0",
"import-fresh": "^3.3.0",
"inquirer": "^7.2.0",
"is-root": "^2.1.0",
"joi": "^17.2.1",
"leven": "^3.1.0",
@ -93,6 +92,7 @@
"pnp-webpack-plugin": "^1.6.4",
"postcss-loader": "^4.1.0",
"postcss-preset-env": "^6.7.0",
"prompts": "^2.4.0",
"react-dev-utils": "^10.2.1",
"react-helmet": "^6.1.0",
"react-loadable": "^5.5.0",

View file

@ -14,7 +14,7 @@ import {execSync} from 'child_process';
import detect from 'detect-port';
import isRoot from 'is-root';
import chalk from 'chalk';
import inquirer from 'inquirer';
import prompts from 'prompts';
const isInteractive = process.stdout.isTTY;
@ -101,7 +101,7 @@ export default async function choosePort(
if (isInteractive) {
clearConsole();
const existingProcess = getProcessForPort(defaultPort);
const question: Record<string, unknown> = {
const question: prompts.PromptObject = {
type: 'confirm',
name: 'shouldChangePort',
message: `${chalk.yellow(
@ -109,10 +109,10 @@ export default async function choosePort(
existingProcess ? ` Probably:\n ${existingProcess}` : ''
}`,
)}\n\nWould you like to run the app on another port instead?`,
default: true,
initial: true,
};
inquirer.prompt(question).then((answer: any) => {
if (answer.shouldChangePort) {
prompts(question).then((answer: any) => {
if (answer.shouldChangePort === true) {
resolve(port);
} else {
resolve(null);