import inquirer from 'inquirer' import { Answer } from '../../models/choice' import { isEmail } from '../../utils/checker.util' import { showInfo } from '../../utils/logger.util' export async function emailQuestion(): Promise { return inquirer.prompt([ { name: 'email', type: 'input', message: `Please, specify your email address:`, }, ]) } export const getProviderEmail = async (): Promise => { const { email }: Answer = await emailQuestion() console.log(email) if (!isEmail(email)) { showInfo('Wrong email. Please try again.') return getProviderEmail() } return email }