xdg-basedir
Advanced tools
Comparing version 1.0.0 to 1.0.1
20
index.js
@@ -6,14 +6,22 @@ 'use strict'; | ||
exports.data = env.XDG_DATA_HOME || path.join(userHome, '.local', 'share'); | ||
exports.data = env.XDG_DATA_HOME || | ||
(userHome ? path.join(userHome, '.local', 'share') : null); | ||
exports.config = env.XDG_CONFIG_HOME || path.join(userHome, '.config'); | ||
exports.config = env.XDG_CONFIG_HOME || | ||
(userHome ? path.join(userHome, '.config') : null); | ||
exports.cache = env.XDG_CONFIG_HOME || path.join(userHome, '.cache'); | ||
exports.cache = env.XDG_CONFIG_HOME || (userHome ? path.join(userHome, '.cache') : null); | ||
exports.runtime = env.XDG_RUNTIME_DIR; | ||
exports.runtime = env.XDG_RUNTIME_DIR || null; | ||
exports.dataDirs = (env.XDG_DATA_DIRS || '/usr/local/share/:/usr/share/').split(':'); | ||
exports.dataDirs.unshift(exports.data); | ||
if (exports.data) { | ||
exports.dataDirs.unshift(exports.data); | ||
} | ||
exports.configDirs = (env.XDG_CONFIG_DIRS || '/etc/xdg').split(':'); | ||
exports.configDirs.unshift(exports.config); | ||
if (exports.config) { | ||
exports.configDirs.unshift(exports.config); | ||
} |
{ | ||
"name": "xdg-basedir", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Get XDG Base Directory paths", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -31,2 +31,4 @@ # xdg-basedir [![Build Status](https://travis-ci.org/sindresorhus/xdg-basedir.svg?branch=master)](https://travis-ci.org/sindresorhus/xdg-basedir) | ||
The 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). | ||
### .data | ||
@@ -33,0 +35,0 @@ |
4093
4
18
61