Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Block: Migrate Inquirer.js dependency to the new API #67877

Merged
merged 11 commits into from
Dec 19, 2024
19 changes: 12 additions & 7 deletions bin/plugin/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
// @ts-ignore
const inquirer = require( 'inquirer' );
const { confirm } = require( '@inquirer/prompts' );
const fs = require( 'fs' );
const childProcess = require( 'child_process' );
const { v4: uuid } = require( 'uuid' );
Expand Down Expand Up @@ -97,14 +97,19 @@ async function askForConfirmation(
isDefault = true,
abortMessage = 'Aborting.'
) {
const { isReady } = await inquirer.prompt( [
{
type: 'confirm',
name: 'isReady',
let isReady = false;
try {
isReady = await confirm( {
default: isDefault,
message,
},
] );
} );
} catch ( error ) {
if ( error instanceof Error && error.name === 'ExitPromptError' ) {
console.log( 'Cancelled.' );
process.exit( 1 );
}
throw error;
}

if ( ! isReady ) {
log( formats.error( '\n' + abortMessage ) );
Expand Down
Loading
Loading