import inquirer from "inquirer" ; import { logger } from "../deps" ; param message param yes param default export async function confirmWithUser ( message , yes ? , defaultAnswer ? ) { if ( process . env . QUIET ) { return true ; } if ( ! ! yes ) { if ( ! process . env . QUIET ) { logger . info ( `${ message } (Y/n): y` ) ; } return true ; } defaultAnswer = defaultAnswer ?? "y" ; const isDefaultYes = defaultAnswer === "y" ; const choices = `(${ isDefaultYes ? "Y" : "y" }/${ isDefaultYes ? "n" : "N" })` ; const res = await inquirer . prompt ( [ { name : "continue" , message : `${ message } ${ choices }` , default : defaultAnswer , } , ] ) ; return [ "y" , "yes" ] . includes ( res . continue . toLowerCase ( ) ) ; }