/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import * as inquirer from 'inquirer'; import { isTTY } from './tty'; export async function askConfirmation( message: string, defaultResponse: boolean, noTTYResponse?: boolean, ): Promise { if (!isTTY()) { return noTTYResponse ?? defaultResponse; } const question: inquirer.Question = { type: 'confirm', name: 'confirmation', prefix: '', message, default: defaultResponse, }; const answers = await inquirer.prompt([question]); return answers['confirmation']; }