Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
index.js | D | 12-May-2024 | 720 | 29 | 19 | |
license | D | 12-May-2024 | 1.1 KiB | 22 | 17 | |
package.json | D | 12-May-2024 | 1.6 KiB | 74 | 73 | |
readme.md | D | 12-May-2024 | 1.5 KiB | 61 | 32 |
readme.md
1# xdg-basedir [![Build Status](https://travis-ci.org/sindresorhus/xdg-basedir.svg?branch=master)](https://travis-ci.org/sindresorhus/xdg-basedir) 2 3> Get [XDG Base Directory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) paths 4 5 6## Install 7 8``` 9$ npm install --save xdg-basedir 10``` 11 12 13## Usage 14 15```js 16const xdgBasedir = require('xdg-basedir'); 17 18xdgBasedir.data; 19//=> '/home/sindresorhus/.local/share' 20 21xdgBasedir.config; 22//=> '/home/sindresorhus/.config' 23 24xdgBasedir.dataDirs 25//=> ['/home/sindresorhus/.local/share', '/usr/local/share/', '/usr/share/'] 26``` 27 28 29## API 30 31The properties `.data`, `.config`, `.cache`, `.runtime` will return `null` 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 temp directory](https://github.com/yeoman/configstore/blob/b82690fc401318ad18dcd7d151a0003a4898a314/index.js#L15). 32 33### .data 34 35Directory for user specific data files. 36 37### .config 38 39Directory for user specific configuration files. 40 41### .cache 42 43Directory for user specific non-essential data files. 44 45### .runtime 46 47Directory for user-specific non-essential runtime files and other file objects (such as sockets, named pipes, etc). 48 49### .dataDirs 50 51Preference-ordered array of base directories to search for data files in addition to `.data`. 52 53### .configDirs 54 55Preference-ordered array of base directories to search for configuration files in addition to `.config`. 56 57 58## License 59 60MIT © [Sindre Sorhus](https://sindresorhus.com) 61