import path from 'path' ; import { existsSync } from 'fs' ; import { InvalidLocalConfig } from '../errors' ; import { ConflictingConfigFiles } from '../errors-ts' ; import getArgs from '../../util/get-args' ; export default function getLocalPathConfig ( prefix ) { let customPath ; const argv = getArgs ( process . argv . slice ( 2 ) , { } , { permissive : true } ) ; customPath = argv [ '--local-config' ] ; if ( customPath ) { if ( typeof customPath !== 'string' ) { throw new InvalidLocalConfig ( customPath ) ; } return path . resolve ( prefix , customPath ) ; } const vercelConfigPath = path . join ( prefix , 'vercel.json' ) ; const nowConfigPath = path . join ( prefix , 'now.json' ) ; const vercelConfigExists = existsSync ( vercelConfigPath ) ; const nowConfigExists = existsSync ( nowConfigPath ) ; if ( nowConfigExists && vercelConfigExists ) { throw new ConflictingConfigFiles ( [ vercelConfigPath , nowConfigPath ] ) ; } if ( nowConfigExists ) { return nowConfigPath ; } return vercelConfigPath ; }