summaryrefslogtreecommitdiff
path: root/node_modules/env-paths
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/env-paths')
-rw-r--r--node_modules/env-paths/index.js69
-rw-r--r--node_modules/env-paths/license21
-rw-r--r--node_modules/env-paths/package.json46
-rw-r--r--node_modules/env-paths/readme.md71
4 files changed, 207 insertions, 0 deletions
diff --git a/node_modules/env-paths/index.js b/node_modules/env-paths/index.js
new file mode 100644
index 0000000..4a04b71
--- /dev/null
+++ b/node_modules/env-paths/index.js
@@ -0,0 +1,69 @@
+'use strict';
+const path = require('path');
+const os = require('os');
+
+const homedir = os.homedir();
+const tmpdir = os.tmpdir();
+const env = process.env;
+
+const macos = name => {
+ const library = path.join(homedir, 'Library');
+
+ return {
+ data: path.join(library, 'Application Support', name),
+ config: path.join(library, 'Preferences', name),
+ cache: path.join(library, 'Caches', name),
+ log: path.join(library, 'Logs', name),
+ temp: path.join(tmpdir, name)
+ };
+};
+
+const windows = name => {
+ const appData = env.LOCALAPPDATA || path.join(homedir, 'AppData', 'Local');
+
+ return {
+ // data/config/cache/log are invented by me as Windows isn't opinionated about this
+ data: path.join(appData, name, 'Data'),
+ config: path.join(appData, name, 'Config'),
+ cache: path.join(appData, name, 'Cache'),
+ log: path.join(appData, name, 'Log'),
+ temp: path.join(tmpdir, name)
+ };
+};
+
+// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
+const linux = name => {
+ const username = path.basename(homedir);
+
+ return {
+ data: path.join(env.XDG_DATA_HOME || path.join(homedir, '.local', 'share'), name),
+ config: path.join(env.XDG_CONFIG_HOME || path.join(homedir, '.config'), name),
+ cache: path.join(env.XDG_CACHE_HOME || path.join(homedir, '.cache'), name),
+ // https://wiki.debian.org/XDGBaseDirectorySpecification#state
+ log: path.join(env.XDG_STATE_HOME || path.join(homedir, '.local', 'state'), name),
+ temp: path.join(tmpdir, username, name)
+ };
+};
+
+module.exports = (name, opts) => {
+ if (typeof name !== 'string') {
+ throw new TypeError(`Expected string, got ${typeof name}`);
+ }
+
+ opts = Object.assign({suffix: 'nodejs'}, opts);
+
+ if (opts.suffix) {
+ // add suffix to prevent possible conflict with native apps
+ name += `-${opts.suffix}`;
+ }
+
+ if (process.platform === 'darwin') {
+ return macos(name);
+ }
+
+ if (process.platform === 'win32') {
+ return windows(name);
+ }
+
+ return linux(name);
+};
diff --git a/node_modules/env-paths/license b/node_modules/env-paths/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/node_modules/env-paths/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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.
diff --git a/node_modules/env-paths/package.json b/node_modules/env-paths/package.json
new file mode 100644
index 0000000..74773ce
--- /dev/null
+++ b/node_modules/env-paths/package.json
@@ -0,0 +1,46 @@
+{
+ "name": "env-paths",
+ "version": "1.0.0",
+ "description": "Get paths for storing things like data, config, cache, etc",
+ "license": "MIT",
+ "repository": "sindresorhus/env-paths",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "common",
+ "user",
+ "paths",
+ "env",
+ "environment",
+ "directory",
+ "dir",
+ "appdir",
+ "path",
+ "data",
+ "config",
+ "cache",
+ "logs",
+ "temp",
+ "linux",
+ "unix"
+ ],
+ "devDependencies": {
+ "ava": "*",
+ "xo": "*"
+ },
+ "xo": {
+ "esnext": true
+ }
+}
diff --git a/node_modules/env-paths/readme.md b/node_modules/env-paths/readme.md
new file mode 100644
index 0000000..0bdc2ac
--- /dev/null
+++ b/node_modules/env-paths/readme.md
@@ -0,0 +1,71 @@
+# env-paths [![Build Status](https://travis-ci.org/sindresorhus/env-paths.svg?branch=master)](https://travis-ci.org/sindresorhus/env-paths)
+
+> Get paths for storing things like data, config, cache, etc
+
+
+## Install
+
+```
+$ npm install --save env-paths
+```
+
+
+## Usage
+
+```js
+const envPaths = require('env-paths');
+const paths = envPaths('MyApp');
+
+paths.data;
+//=> '/home/sindresorhus/.local/share/MyApp-nodejs'
+
+paths.config
+//=> '/home/sindresorhus/.config/MyApp-nodejs'
+```
+
+
+## API
+
+### paths = envPaths(name, [options])
+
+#### name
+
+Type: `string`
+
+Name of your project. Used to generate the paths.
+
+#### options
+
+##### suffix
+
+Type: `string`<br>
+Default: `'nodejs'`
+
+**Don't use this option unless you really have to!**<br>
+Suffix appended to the project name to avoid name conflicts with native
+apps. Pass an empty string to disable it.
+
+### paths.data
+
+Directory for data files.
+
+### paths.config
+
+Directory for config files.
+
+### paths.cache
+
+Directory for non-essential data files.
+
+### paths.log
+
+Directory for log files.
+
+### paths.temp
+
+Directory for temporary files.
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)