🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

app-cache-dir

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

app-cache-dir

Get a path of the standard cache directory for a given application

latest
Source
npmnpm
Version
0.4.0
Version published
Weekly downloads
68
-50.72%
Maintainers
1
Weekly downloads
 
Created
Source

app-cache-dir

npm version Build Status Build status Coverage Status

Get a path of the standard cache directory for a given application

const appCacheDir = require('app-cache-dir');

// On most Linuxes
appCacheDir('my-app'); //=> '/root/shinnn/.cache/my-app'

// On macOS
appCacheDir('my-app'); //=> '/Users/shinnn/.cache/my-app'

// On Windows
appCacheDir('my-app'); //=> 'C:\\Users\\shinnn\\AppData\\Local\\my-app\\cache'

Installation

Use npm.

npm install app-cache-dir

API

const appCacheDir = require('app-cache-dir');

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 POSIX
  • C:\\Users\\${username}\\AppData\Local\${appName}\cache on Windows
// On macOS

appCacheDir('hi'); //=> '/Users/shinnn/.cache/hi'

process.env.XDG_CACHE_HOME = '/foo/bar/';

appCacheDir('hi'); //=> '/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

Keywords

application

FAQs

Package last updated on 26 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts