@dada78641/env-paths
v0.1.0
Published
Library for determining platform-specific data paths
Downloads
50
Readme
@dada78641/env-paths
Library for determining platform-specific data paths.
This is mainly based on the sindresorhus/env-paths package, with the main difference being that this library will utilize the XDG Base Directory specification even on macOS, if the XDG_*_HOME
variables are set.
Usage
npm i @dada78641/env-paths
import {createEnvPaths} from '@dada78641/env-paths'
export const envPaths = createEnvPaths('my_program')
Example output
Running the code as above will return paths such as these:
†: This path will typically be a symlink to someplace else, usually a path starting with /private/var/folders
.
XDG variables
The following XDG variables are recognized on Linux and macOS:
| Variable | Key | Description |
|:---------|:--------|:------------|
| XDG_DATA_HOME
| data
| Data files produced by the application |
| XDG_CONFIG_HOME
| config
| Settings, preferences, etc. |
| XDG_CACHE_HOME
| cache
| Cache files (should always be deletable) |
| XDG_STATE_HOME
| log
| Session files, logs, history files, etc. |
License
MIT licensed.