How to use the prompts/lib/elements.ConfirmPrompt function in prompts

To help you get started, we’ve selected a few prompts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chanzo / script-launcher / src / common.ts View on Github external
export async function confirmPrompt(message: string, autoValue?: boolean): Promise {
  const confirmPrompt = new ConfirmPrompt({
    type: 'confirm',
    name: 'value',
    initial: autoValue !== undefined ? autoValue : false,
    message: message,
  });

  const confirmPromise = toPromise(confirmPrompt);

  if (autoValue !== undefined) confirmPrompt.submit();

  const choice = await confirmPromise;

  return choice[0] as boolean;
}