pax_global_header00006660000000000000000000000064130502764450014520gustar00rootroot0000000000000052 comment=d441833e9dad9694b04495905ab8fe484e3b8b99 xdg-basedir-3.0.0/000077500000000000000000000000001305027644500137115ustar00rootroot00000000000000xdg-basedir-3.0.0/.editorconfig000066400000000000000000000002761305027644500163730ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 xdg-basedir-3.0.0/.gitattributes000066400000000000000000000000351305027644500166020ustar00rootroot00000000000000* text=auto *.js text eol=lf xdg-basedir-3.0.0/.gitignore000066400000000000000000000000151305027644500156750ustar00rootroot00000000000000node_modules xdg-basedir-3.0.0/.travis.yml000066400000000000000000000000671305027644500160250ustar00rootroot00000000000000sudo: false language: node_js node_js: - '6' - '4' xdg-basedir-3.0.0/index.js000066400000000000000000000013201305027644500153520ustar00rootroot00000000000000'use strict'; const os = require('os'); const path = require('path'); const home = os.homedir(); const env = process.env; exports.data = env.XDG_DATA_HOME || (home ? path.join(home, '.local', 'share') : null); exports.config = env.XDG_CONFIG_HOME || (home ? path.join(home, '.config') : null); exports.cache = env.XDG_CACHE_HOME || (home ? path.join(home, '.cache') : null); exports.runtime = env.XDG_RUNTIME_DIR || null; exports.dataDirs = (env.XDG_DATA_DIRS || '/usr/local/share/:/usr/share/').split(':'); if (exports.data) { exports.dataDirs.unshift(exports.data); } exports.configDirs = (env.XDG_CONFIG_DIRS || '/etc/xdg').split(':'); if (exports.config) { exports.configDirs.unshift(exports.config); } xdg-basedir-3.0.0/license000066400000000000000000000021371305027644500152610ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. xdg-basedir-3.0.0/package.json000066400000000000000000000012251305027644500161770ustar00rootroot00000000000000{ "name": "xdg-basedir", "version": "3.0.0", "description": "Get XDG Base Directory paths", "license": "MIT", "repository": "sindresorhus/xdg-basedir", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=4" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "keywords": [ "xdg", "base", "directory", "dir", "basedir", "path", "data", "config", "cache", "linux", "unix", "spec" ], "devDependencies": { "ava": "*", "require-uncached": "^1.0.2", "xo": "*" } } xdg-basedir-3.0.0/readme.md000066400000000000000000000030561305027644500154740ustar00rootroot00000000000000# xdg-basedir [![Build Status](https://travis-ci.org/sindresorhus/xdg-basedir.svg?branch=master)](https://travis-ci.org/sindresorhus/xdg-basedir) > Get [XDG Base Directory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) paths ## Install ``` $ npm install --save xdg-basedir ``` ## Usage ```js const xdgBasedir = require('xdg-basedir'); xdgBasedir.data; //=> '/home/sindresorhus/.local/share' xdgBasedir.config; //=> '/home/sindresorhus/.config' xdgBasedir.dataDirs //=> ['/home/sindresorhus/.local/share', '/usr/local/share/', '/usr/share/'] ``` ## API 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 Directory for user specific data files. ### .config Directory for user specific configuration files. ### .cache Directory for user specific non-essential data files. ### .runtime Directory for user-specific non-essential runtime files and other file objects (such as sockets, named pipes, etc). ### .dataDirs Preference-ordered array of base directories to search for data files in addition to `.data`. ### .configDirs Preference-ordered array of base directories to search for configuration files in addition to `.config`. ## License MIT © [Sindre Sorhus](https://sindresorhus.com) xdg-basedir-3.0.0/test.js000066400000000000000000000022071305027644500152270ustar00rootroot00000000000000import {serial as test} from 'ava'; import requireUncached from 'require-uncached'; test('.data', t => { process.env.XDG_DATA_HOME = 'data'; const xdgBasedir = requireUncached('.'); t.is(xdgBasedir.data, 'data'); }); test('.config', t => { process.env.XDG_CONFIG_HOME = 'config'; const xdgBasedir = requireUncached('.'); t.is(xdgBasedir.config, 'config'); }); test('.cache', t => { process.env.XDG_CACHE_HOME = 'cache'; const xdgBasedir = requireUncached('.'); t.is(xdgBasedir.cache, 'cache'); }); test('.runtime', t => { process.env.XDG_RUNTIME_DIR = 'runtime'; const xdgBasedir = requireUncached('.'); t.is(xdgBasedir.runtime, 'runtime'); }); test('.dataDirs', t => { process.env.XDG_DATA_DIRS = 'dirs:data_dirs'; const xdgBasedir = requireUncached('.'); t.is(xdgBasedir.dataDirs[0], 'data'); t.is(xdgBasedir.dataDirs[1], 'dirs'); t.is(xdgBasedir.dataDirs[2], 'data_dirs'); }); test('.configDirs', t => { process.env.XDG_CONFIG_DIRS = 'dirs:config_dirs'; const xdgBasedir = requireUncached('.'); t.is(xdgBasedir.configDirs[0], 'config'); t.is(xdgBasedir.configDirs[1], 'dirs'); t.is(xdgBasedir.configDirs[2], 'config_dirs'); });