summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/configstore
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/configstore')
-rw-r--r--deps/npm/node_modules/configstore/index.js106
-rw-r--r--deps/npm/node_modules/configstore/license9
-rw-r--r--deps/npm/node_modules/configstore/package.json79
-rw-r--r--deps/npm/node_modules/configstore/readme.md116
4 files changed, 310 insertions, 0 deletions
diff --git a/deps/npm/node_modules/configstore/index.js b/deps/npm/node_modules/configstore/index.js
new file mode 100644
index 0000000000..fb944204be
--- /dev/null
+++ b/deps/npm/node_modules/configstore/index.js
@@ -0,0 +1,106 @@
+'use strict';
+const path = require('path');
+const os = require('os');
+const fs = require('graceful-fs');
+const makeDir = require('make-dir');
+const xdgBasedir = require('xdg-basedir');
+const writeFileAtomic = require('write-file-atomic');
+const dotProp = require('dot-prop');
+const uniqueString = require('unique-string');
+
+const configDir = xdgBasedir.config || path.join(os.tmpdir(), uniqueString());
+const permissionError = 'You don\'t have access to this file.';
+const makeDirOptions = {mode: 0o0700};
+const writeFileOptions = {mode: 0o0600};
+
+class Configstore {
+ constructor(id, defaults, opts) {
+ opts = opts || {};
+
+ const pathPrefix = opts.globalConfigPath ?
+ path.join(id, 'config.json') :
+ path.join('configstore', `${id}.json`);
+
+ this.path = path.join(configDir, pathPrefix);
+ this.all = Object.assign({}, defaults, this.all);
+ }
+
+ get all() {
+ try {
+ return JSON.parse(fs.readFileSync(this.path, 'utf8'));
+ } catch (err) {
+ // Create dir if it doesn't exist
+ if (err.code === 'ENOENT') {
+ makeDir.sync(path.dirname(this.path), makeDirOptions);
+ return {};
+ }
+
+ // Improve the message of permission errors
+ if (err.code === 'EACCES') {
+ err.message = `${err.message}\n${permissionError}\n`;
+ }
+
+ // Empty the file if it encounters invalid JSON
+ if (err.name === 'SyntaxError') {
+ writeFileAtomic.sync(this.path, '', writeFileOptions);
+ return {};
+ }
+
+ throw err;
+ }
+ }
+
+ set all(val) {
+ try {
+ // Make sure the folder exists as it could have been deleted in the meantime
+ makeDir.sync(path.dirname(this.path), makeDirOptions);
+
+ writeFileAtomic.sync(this.path, JSON.stringify(val, null, '\t'), writeFileOptions);
+ } catch (err) {
+ // Improve the message of permission errors
+ if (err.code === 'EACCES') {
+ err.message = `${err.message}\n${permissionError}\n`;
+ }
+
+ throw err;
+ }
+ }
+
+ get size() {
+ return Object.keys(this.all || {}).length;
+ }
+
+ get(key) {
+ return dotProp.get(this.all, key);
+ }
+
+ set(key, val) {
+ const config = this.all;
+
+ if (arguments.length === 1) {
+ for (const k of Object.keys(key)) {
+ dotProp.set(config, k, key[k]);
+ }
+ } else {
+ dotProp.set(config, key, val);
+ }
+
+ this.all = config;
+ }
+
+ has(key) {
+ return dotProp.has(this.all, key);
+ }
+
+ delete(key) {
+ const config = this.all;
+ dotProp.delete(config, key);
+ this.all = config;
+ }
+
+ clear() {
+ this.all = {};
+ }
+}
+
+module.exports = Configstore;
diff --git a/deps/npm/node_modules/configstore/license b/deps/npm/node_modules/configstore/license
new file mode 100644
index 0000000000..be304e2ddc
--- /dev/null
+++ b/deps/npm/node_modules/configstore/license
@@ -0,0 +1,9 @@
+Copyright Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/deps/npm/node_modules/configstore/package.json b/deps/npm/node_modules/configstore/package.json
new file mode 100644
index 0000000000..828dc2ae6a
--- /dev/null
+++ b/deps/npm/node_modules/configstore/package.json
@@ -0,0 +1,79 @@
+{
+ "_from": "configstore@^3.0.0",
+ "_id": "configstore@3.1.2",
+ "_inBundle": false,
+ "_integrity": "sha512-vtv5HtGjcYUgFrXc6Kx747B83MRRVS5R1VTEQoXvuP+kMI+if6uywV0nDGoiydJRy4yk7h9od5Og0kxx4zUXmw==",
+ "_location": "/configstore",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "configstore@^3.0.0",
+ "name": "configstore",
+ "escapedName": "configstore",
+ "rawSpec": "^3.0.0",
+ "saveSpec": null,
+ "fetchSpec": "^3.0.0"
+ },
+ "_requiredBy": [
+ "/update-notifier"
+ ],
+ "_resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.2.tgz",
+ "_shasum": "c6f25defaeef26df12dd33414b001fe81a543f8f",
+ "_spec": "configstore@^3.0.0",
+ "_where": "/Users/rebecca/code/npm/node_modules/update-notifier",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "bugs": {
+ "url": "https://github.com/yeoman/configstore/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "dot-prop": "^4.1.0",
+ "graceful-fs": "^4.1.2",
+ "make-dir": "^1.0.0",
+ "unique-string": "^1.0.0",
+ "write-file-atomic": "^2.0.0",
+ "xdg-basedir": "^3.0.0"
+ },
+ "deprecated": false,
+ "description": "Easily load and save config without having to think about where and how",
+ "devDependencies": {
+ "ava": "*",
+ "xo": "*"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "files": [
+ "index.js"
+ ],
+ "homepage": "https://github.com/yeoman/configstore#readme",
+ "keywords": [
+ "config",
+ "store",
+ "storage",
+ "conf",
+ "configuration",
+ "settings",
+ "preferences",
+ "json",
+ "data",
+ "persist",
+ "persistent",
+ "save"
+ ],
+ "license": "BSD-2-Clause",
+ "name": "configstore",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/yeoman/configstore.git"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "version": "3.1.2"
+}
diff --git a/deps/npm/node_modules/configstore/readme.md b/deps/npm/node_modules/configstore/readme.md
new file mode 100644
index 0000000000..6af37719bc
--- /dev/null
+++ b/deps/npm/node_modules/configstore/readme.md
@@ -0,0 +1,116 @@
+# configstore [![Build Status](https://travis-ci.org/yeoman/configstore.svg?branch=master)](https://travis-ci.org/yeoman/configstore)
+
+> Easily load and persist config without having to think about where and how
+
+Config is stored in a JSON file located in `$XDG_CONFIG_HOME` or `~/.config`.<br>
+Example: `~/.config/configstore/some-id.json`
+
+*If you need this for Electron, check out [`electron-store`](https://github.com/sindresorhus/electron-store) instead.*
+
+
+## Usage
+
+```js
+const Configstore = require('configstore');
+const pkg = require('./package.json');
+
+// create a Configstore instance with an unique ID e.g.
+// Package name and optionally some default values
+const conf = new Configstore(pkg.name, {foo: 'bar'});
+
+console.log(conf.get('foo'));
+//=> 'bar'
+
+conf.set('awesome', true);
+console.log(conf.get('awesome'));
+//=> true
+
+// Use dot-notation to access nested properties
+conf.set('bar.baz', true);
+console.log(conf.get('bar'));
+//=> {baz: true}
+
+conf.delete('awesome');
+console.log(conf.get('awesome'));
+//=> undefined
+```
+
+
+## API
+
+### Configstore(packageName, [defaults], [options])
+
+Returns a new instance.
+
+#### packageName
+
+Type: `string`
+
+Name of your package.
+
+#### defaults
+
+Type: `Object`
+
+Default config.
+
+#### options
+
+##### globalConfigPath
+
+Type: `boolean`<br>
+Default: `false`
+
+Store the config at `$CONFIG/package-name/config.json` instead of the default `$CONFIG/configstore/package-name.json`. This is not recommended as you might end up conflicting with other tools, rendering the "without having to think" idea moot.
+
+### Instance
+
+You can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a `key` to access nested properties.
+
+### .set(key, value)
+
+Set an item.
+
+### .set(object)
+
+Set multiple items at once.
+
+### .get(key)
+
+Get an item.
+
+### .has(key)
+
+Check if an item exists.
+
+### .delete(key)
+
+Delete an item.
+
+### .clear()
+
+Delete all items.
+
+### .size
+
+Get the item count.
+
+### .path
+
+Get the path to the config file. Can be used to show the user where the config file is located or even better open it for them.
+
+### .all
+
+Get all the config as an object or replace the current config with an object:
+
+```js
+conf.all = {
+ hello: 'world'
+};
+```
+
+
+## License
+
+[BSD license](http://opensource.org/licenses/bsd-license.php)<br>
+Copyright Google