import path from 'path' ; import chalk from 'chalk' ; import inquirer from 'inquirer' ; import { Output } from '../output' ; import { validateRootDirectory } from '../validate-paths' ; export async function inputRootDirectory ( cwd , output , autoConfirm = false ) { if ( autoConfirm ) { return null ; } while ( true ) { const { rootDirectory } = await inquirer . prompt ( { type : 'input' , name : 'rootDirectory' , message : `In which directory is your code located?` , transformer : ( input ) => { return `${ chalk . dim ( `./` ) }${ input }` ; } , } ) ; if ( ! rootDirectory ) { return null ; } const normal = path . normalize ( rootDirectory ) ; if ( normal === '.' || normal === './' ) { return null ; } const fullPath = path . join ( cwd , normal ) ; if ( ( await validateRootDirectory ( output , cwd , fullPath , 'Please choose a different one.' ) ) === false ) { continue ; } return normal ; } }