import { homedir } from "os" ; import path from "path" ; const appName = "adapt" ; function localAppData ( ) { const appData = process . env . LOCALAPPDATA ; if ( ! appData ) throw new Error ( `Environment variable LOCALAPPDATA is not set` ) ; return appData ; } export function xdgCacheDir ( ) { let cacheHome = process . env . XDG_CACHE_HOME ; if ( ! cacheHome ) { switch ( process . platform ) { case "darwin" : cacheHome = path . join ( homedir ( ) , "Library" , "Caches" ) ; break ; case "win32" : cacheHome = localAppData ( ) ; break ; default : cacheHome = path . join ( homedir ( ) , ".cache" ) ; break ; } } return path . join ( cacheHome , appName ) ; }