app-cache-dir
Get a path of the standard cache directory for a given application
const appCacheDir = ; // On most Linuxes; //=> '/root/shinnn/.cache/my-app' // On macOS; //=> '/Users/shinnn/.cache/my-app' // On Windows; //=> 'C:\\Users\\shinnn\\AppData\\Local\\my-app\\cache'
Installation
npm install app-cache-dir
API
const appCacheDir = ;
appCacheDir(appName)
appName: string
(application name)
Return: string
(absolute directory path)
It resolves an application name into its standard cache directory presented in the Atom issue tracker, with following the environment variables XDG_CACHE_HOME
(POSIX) and LOCALAPPDATA
(Windows).
Basically it results:
~/.cache/${appName}
on POSIXC:\\Users\\${username}\\AppData\Local\${appName}\cache
on Windows
// On macOS ; //=> '/Users/shinnn/.cache/hi' processenvXDG_CACHE_HOME = '/foo/bar/'; ; //=> '/foo/bar/hi'
When it cannot resolve the cache path, for exmaple both HOME
and XDG_CACHE_HOME
are empty, it returns ${os.tmpdir()}/${appName}/cache
as a last resort.
appCacheDir.posix(appName)
appName: string
Return: string
Follow POSIX way regardless of the current OS.
appCacheDir.win32(appName)
appName: string
Return: string
Follow Windows way regardless of the current OS.
License
ISC License © 2017 - 2018 Shinnosuke Watanabe