Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/env-paths
Get paths for storing things like data, config, cache, etc
https://github.com/sindresorhus/env-paths
Last synced: 4 days ago
JSON representation
Get paths for storing things like data, config, cache, etc
- Host: GitHub
- URL: https://github.com/sindresorhus/env-paths
- Owner: sindresorhus
- License: mit
- Created: 2016-06-21T21:25:15.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-07-02T07:17:55.000Z (6 months ago)
- Last Synced: 2024-10-29T15:46:30.872Z (about 2 months ago)
- Language: JavaScript
- Size: 23.4 KB
- Stars: 379
- Watchers: 8
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
- Security: .github/security.md
Awesome Lists containing this project
- awesome-starred-test - sindresorhus/env-paths - Get paths for storing things like data, config, cache, etc (JavaScript)
README
# env-paths
> Get paths for storing things like data, config, cache, etc
Uses the correct OS-specific paths. Most developers get this wrong.
## Install
```
$ npm install env-paths
```## Usage
```js
import envPaths from 'env-paths';const paths = envPaths('MyApp');
paths.data;
//=> '/home/sindresorhus/.local/share/MyApp-nodejs'paths.config
//=> '/home/sindresorhus/.config/MyApp-nodejs'
```## API
### paths = envPaths(name, options?)
Note: It only generates the path strings. It doesn't create the directories for you. You could use [`make-dir`](https://github.com/sindresorhus/make-dir) to create the directories.
#### name
Type: `string`
The name of your project. Used to generate the paths.
#### options
Type: `object`
##### suffix
Type: `string`\
Default: `'nodejs'`**Don't use this option unless you really have to!**
Suffix appended to the project name to avoid name conflicts with native
apps. Pass an empty string to disable it.### paths.data
Directory for data files.
Example locations (with the default `nodejs` [suffix](#suffix)):
- macOS: `~/Library/Application Support/MyApp-nodejs`
- Windows: `%LOCALAPPDATA%\MyApp-nodejs\Data` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Data`)
- Linux: `~/.local/share/MyApp-nodejs` (or `$XDG_DATA_HOME/MyApp-nodejs`)### paths.config
Directory for config files.
Example locations (with the default `nodejs` [suffix](#suffix)):
- macOS: `~/Library/Preferences/MyApp-nodejs`
- Windows: `%APPDATA%\MyApp-nodejs\Config` (for example, `C:\Users\USERNAME\AppData\Roaming\MyApp-nodejs\Config`)
- Linux: `~/.config/MyApp-nodejs` (or `$XDG_CONFIG_HOME/MyApp-nodejs`)### paths.cache
Directory for non-essential data files.
Example locations (with the default `nodejs` [suffix](#suffix)):
- macOS: `~/Library/Caches/MyApp-nodejs`
- Windows: `%LOCALAPPDATA%\MyApp-nodejs\Cache` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Cache`)
- Linux: `~/.cache/MyApp-nodejs` (or `$XDG_CACHE_HOME/MyApp-nodejs`)### paths.log
Directory for log files.
Example locations (with the default `nodejs` [suffix](#suffix)):
- macOS: `~/Library/Logs/MyApp-nodejs`
- Windows: `%LOCALAPPDATA%\MyApp-nodejs\Log` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Log`)
- Linux: `~/.local/state/MyApp-nodejs` (or `$XDG_STATE_HOME/MyApp-nodejs`)### paths.temp
Directory for temporary files.
Example locations (with the default `nodejs` [suffix](#suffix)):
- macOS: `/var/folders/jf/f2twvvvs5jl_m49tf034ffpw0000gn/T/MyApp-nodejs`
- Windows: `%LOCALAPPDATA%\Temp\MyApp-nodejs` (for example, `C:\Users\USERNAME\AppData\Local\Temp\MyApp-nodejs`)
- Linux: `/tmp/USERNAME/MyApp-nodejs`---
Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.