import { homedir } from 'os' ; import fs from 'fs' ; import path from 'path' ; import XDGAppPaths from 'xdg-app-paths' ; import getArgs from '../../util/get-args' ; export const isDirectory = ( path ) : boolean => { try { return fs . lstatSync ( path ) . isDirectory ( ) ; } catch ( _ ) { return false ; } } ; const getGlobalPathConfig = ( ) : string => { let customPath ; const argv = getArgs ( process . argv . slice ( 2 ) , { } , { permissive : true } ) ; customPath = argv [ '--global-config' ] ; const vercelDirectories = XDGAppPaths ( 'com.vercel.cli' ) . dataDirs ( ) ; const possibleConfigPaths = [ ... vercelDirectories , path . join ( homedir ( ) , '.now' ) , ... XDGAppPaths ( 'now' ) . dataDirs ( ) , ] ; return ( ( customPath && path . resolve ( customPath ) ) || possibleConfigPaths . find ( configPath => isDirectory ( configPath ) ) || vercelDirectories [ 0 ] ) ; } ; export default getGlobalPathConfig ;