$ gnpm install xdg-basedir
Get XDG Base Directory paths
This package is meant for Linux. You should not use XDG on macOS or Windows. Instead, you should follow their platform conventions. You can use env-paths
for that.
$ npm install xdg-basedir
import {xdgData, xdgConfig, xdgDataDirectories} from 'xdg-basedir';
console.log(xdgData);
//=> '/home/sindresorhus/.local/share'
console.log(xdgConfig);
//=> '/home/sindresorhus/.config'
console.log(xdgDataDirectories);
//=> ['/home/sindresorhus/.local/share', '/usr/local/share/', '/usr/share/']
The exports xdgData
, xdgConfig
, xdgCache
, xdgRuntime
will return undefined
in the uncommon case that both the XDG environment variable is not set and the users home directory can't be found. You need to handle this case. A common solution is to fall back to a temporary directory.
Directory for user-specific data files.
Directory for user-specific configuration files.
Directory for user-specific state files.
Directory for user-specific non-essential data files.
Directory for user-specific non-essential runtime files and other file objects (such as sockets, named pipes, etc).
Preference-ordered array of base directories to search for data files in addition to xdgData
.
Preference-ordered array of base directories to search for configuration files in addition to xdgConfig
.
Copyright 2013 - present © cnpmjs.org | Home |