aboutsummaryrefslogtreecommitdiff
path: root/node_modules/pkg-conf
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-28 00:38:50 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-28 00:40:43 +0200
commit7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (patch)
tree6de9a1aebd150a23b7f8c273ec657a5d0a18fe3e /node_modules/pkg-conf
parent963b7a41feb29cc4be090a2446bdfe0c1f1bcd81 (diff)
downloadwallet-core-7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027.tar.xz
add linting (and some initial fixes)
Diffstat (limited to 'node_modules/pkg-conf')
-rw-r--r--node_modules/pkg-conf/index.js64
-rw-r--r--node_modules/pkg-conf/license21
-rw-r--r--node_modules/pkg-conf/node_modules/find-up/index.js48
-rw-r--r--node_modules/pkg-conf/node_modules/find-up/license21
-rw-r--r--node_modules/pkg-conf/node_modules/find-up/package.json53
-rw-r--r--node_modules/pkg-conf/node_modules/find-up/readme.md85
-rw-r--r--node_modules/pkg-conf/package.json52
-rw-r--r--node_modules/pkg-conf/readme.md104
8 files changed, 448 insertions, 0 deletions
diff --git a/node_modules/pkg-conf/index.js b/node_modules/pkg-conf/index.js
new file mode 100644
index 000000000..dff982790
--- /dev/null
+++ b/node_modules/pkg-conf/index.js
@@ -0,0 +1,64 @@
+'use strict';
+const path = require('path');
+const findUp = require('find-up');
+const loadJsonFile = require('load-json-file');
+
+const filepaths = new WeakMap();
+const filepath = conf => filepaths.get(conf);
+const findNextCwd = pkgPath => path.resolve(path.dirname(pkgPath), '..');
+
+const addFp = (obj, fp) => {
+ filepaths.set(obj, fp);
+ return obj;
+};
+
+const pkgConf = (namespace, opts) => {
+ if (!namespace) {
+ return Promise.reject(new TypeError('Expected a namespace'));
+ }
+
+ opts = opts || {};
+
+ return findUp('package.json', opts.cwd ? {cwd: opts.cwd} : {})
+ .then(fp => {
+ if (!fp) {
+ return addFp(Object.assign({}, opts.defaults), fp);
+ }
+
+ return loadJsonFile(fp).then(pkg => {
+ if (opts.skipOnFalse && pkg[namespace] === false) {
+ const newOpts = Object.assign({}, opts, {cwd: findNextCwd(fp)});
+ return pkgConf(namespace, newOpts);
+ }
+
+ return addFp(Object.assign({}, opts.defaults, pkg[namespace]), fp);
+ });
+ });
+};
+
+const sync = (namespace, opts) => {
+ if (!namespace) {
+ throw new TypeError('Expected a namespace');
+ }
+
+ opts = opts || {};
+
+ const fp = findUp.sync('package.json', opts.cwd ? {cwd: opts.cwd} : {});
+
+ if (!fp) {
+ return addFp(Object.assign({}, opts.defaults), fp);
+ }
+
+ const pkg = loadJsonFile.sync(fp);
+
+ if (opts.skipOnFalse && pkg[namespace] === false) {
+ const newOpts = Object.assign({}, opts, {cwd: findNextCwd(fp)});
+ return sync(namespace, newOpts);
+ }
+
+ return addFp(Object.assign({}, opts.defaults, pkg[namespace]), fp);
+};
+
+module.exports = pkgConf;
+module.exports.filepath = filepath;
+module.exports.sync = sync;
diff --git a/node_modules/pkg-conf/license b/node_modules/pkg-conf/license
new file mode 100644
index 000000000..654d0bfe9
--- /dev/null
+++ b/node_modules/pkg-conf/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/pkg-conf/node_modules/find-up/index.js b/node_modules/pkg-conf/node_modules/find-up/index.js
new file mode 100644
index 000000000..939c9553d
--- /dev/null
+++ b/node_modules/pkg-conf/node_modules/find-up/index.js
@@ -0,0 +1,48 @@
+'use strict';
+const path = require('path');
+const locatePath = require('locate-path');
+
+module.exports = (filename, opts) => {
+ opts = opts || {};
+
+ const startDir = path.resolve(opts.cwd || '');
+ const root = path.parse(startDir).root;
+
+ const filenames = [].concat(filename);
+
+ return new Promise(resolve => {
+ (function find(dir) {
+ locatePath(filenames, {cwd: dir}).then(file => {
+ if (file) {
+ resolve(path.join(dir, file));
+ } else if (dir === root) {
+ resolve(null);
+ } else {
+ find(path.dirname(dir));
+ }
+ });
+ })(startDir);
+ });
+};
+
+module.exports.sync = (filename, opts) => {
+ opts = opts || {};
+
+ let dir = path.resolve(opts.cwd || '');
+ const root = path.parse(dir).root;
+
+ const filenames = [].concat(filename);
+
+ // eslint-disable-next-line no-constant-condition
+ while (true) {
+ const file = locatePath.sync(filenames, {cwd: dir});
+
+ if (file) {
+ return path.join(dir, file);
+ } else if (dir === root) {
+ return null;
+ }
+
+ dir = path.dirname(dir);
+ }
+};
diff --git a/node_modules/pkg-conf/node_modules/find-up/license b/node_modules/pkg-conf/node_modules/find-up/license
new file mode 100644
index 000000000..654d0bfe9
--- /dev/null
+++ b/node_modules/pkg-conf/node_modules/find-up/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/pkg-conf/node_modules/find-up/package.json b/node_modules/pkg-conf/node_modules/find-up/package.json
new file mode 100644
index 000000000..7ec85bb79
--- /dev/null
+++ b/node_modules/pkg-conf/node_modules/find-up/package.json
@@ -0,0 +1,53 @@
+{
+ "name": "find-up",
+ "version": "2.1.0",
+ "description": "Find a file by walking up parent directories",
+ "license": "MIT",
+ "repository": "sindresorhus/find-up",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "find",
+ "up",
+ "find-up",
+ "findup",
+ "look-up",
+ "look",
+ "file",
+ "search",
+ "match",
+ "package",
+ "resolve",
+ "parent",
+ "parents",
+ "folder",
+ "directory",
+ "dir",
+ "walk",
+ "walking",
+ "path"
+ ],
+ "dependencies": {
+ "locate-path": "^2.0.0"
+ },
+ "devDependencies": {
+ "ava": "*",
+ "tempfile": "^1.1.1",
+ "xo": "*"
+ },
+ "xo": {
+ "esnext": true
+ }
+}
diff --git a/node_modules/pkg-conf/node_modules/find-up/readme.md b/node_modules/pkg-conf/node_modules/find-up/readme.md
new file mode 100644
index 000000000..b5ad69455
--- /dev/null
+++ b/node_modules/pkg-conf/node_modules/find-up/readme.md
@@ -0,0 +1,85 @@
+# find-up [![Build Status: Linux and macOS](https://travis-ci.org/sindresorhus/find-up.svg?branch=master)](https://travis-ci.org/sindresorhus/find-up) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/l0cyjmvh5lq72vq2/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/find-up/branch/master)
+
+> Find a file by walking up parent directories
+
+
+## Install
+
+```
+$ npm install --save find-up
+```
+
+
+## Usage
+
+```
+/
+└── Users
+ └── sindresorhus
+ ├── unicorn.png
+ └── foo
+ └── bar
+ ├── baz
+ └── example.js
+```
+
+```js
+// example.js
+const findUp = require('find-up');
+
+findUp('unicorn.png').then(filepath => {
+ console.log(filepath);
+ //=> '/Users/sindresorhus/unicorn.png'
+});
+
+findUp(['rainbow.png', 'unicorn.png']).then(filepath => {
+ console.log(filepath);
+ //=> '/Users/sindresorhus/unicorn.png'
+});
+```
+
+
+## API
+
+### findUp(filename, [options])
+
+Returns a `Promise` for the filepath or `null`.
+
+### findUp([filenameA, filenameB], [options])
+
+Returns a `Promise` for the first filepath found (by respecting the order) or `null`.
+
+### findUp.sync(filename, [options])
+
+Returns a filepath or `null`.
+
+### findUp.sync([filenameA, filenameB], [options])
+
+Returns the first filepath found (by respecting the order) or `null`.
+
+#### filename
+
+Type: `string`
+
+Filename of the file to find.
+
+#### options
+
+##### cwd
+
+Type: `string`<br>
+Default: `process.cwd()`
+
+Directory to start from.
+
+
+## Related
+
+- [find-up-cli](https://github.com/sindresorhus/find-up-cli) - CLI for this module
+- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
+- [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/node_modules/pkg-conf/package.json b/node_modules/pkg-conf/package.json
new file mode 100644
index 000000000..a690d7ca8
--- /dev/null
+++ b/node_modules/pkg-conf/package.json
@@ -0,0 +1,52 @@
+{
+ "name": "pkg-conf",
+ "version": "2.0.0",
+ "description": "Get namespaced config from the closest package.json",
+ "license": "MIT",
+ "repository": "sindresorhus/pkg-conf",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "json",
+ "read",
+ "parse",
+ "file",
+ "fs",
+ "graceful",
+ "load",
+ "pkg",
+ "package",
+ "config",
+ "conf",
+ "configuration",
+ "object",
+ "namespace",
+ "namespaced"
+ ],
+ "dependencies": {
+ "find-up": "^2.0.0",
+ "load-json-file": "^2.0.0"
+ },
+ "devDependencies": {
+ "ava": "*",
+ "xo": "*"
+ },
+ "xo": {
+ "esnext": true
+ },
+ "fixture": {
+ "foo": true
+ }
+}
diff --git a/node_modules/pkg-conf/readme.md b/node_modules/pkg-conf/readme.md
new file mode 100644
index 000000000..4776c227b
--- /dev/null
+++ b/node_modules/pkg-conf/readme.md
@@ -0,0 +1,104 @@
+# pkg-conf [![Build Status](https://travis-ci.org/sindresorhus/pkg-conf.svg?branch=master)](https://travis-ci.org/sindresorhus/pkg-conf)
+
+> Get namespaced config from the closest package.json
+
+Having tool specific config in package.json reduces the amount of metafiles in your repo (there are usually a lot!) and makes the config obvious compared to hidden dotfiles like `.eslintrc`, which can end up causing confusion. [XO](https://github.com/sindresorhus/xo), for example, uses the `xo` namespace in package.json, and [ESLint](http://eslint.org) uses `eslintConfig`. Many more tools supports this, like [AVA](https://ava.li), [Babel](https://babeljs.io), [nyc](https://github.com/istanbuljs/nyc), etc.
+
+
+## Install
+
+```
+$ npm install --save pkg-conf
+```
+
+
+## Usage
+
+```json
+{
+ "name": "some-package",
+ "version": "1.0.0",
+ "unicorn": {
+ "rainbow": true
+ }
+}
+```
+
+```js
+const pkgConf = require('pkg-conf');
+
+pkgConf('unicorn').then(config => {
+ console.log(config.rainbow);
+ //=> true
+});
+```
+
+
+## API
+
+It [walks up](https://github.com/sindresorhus/find-up) parent directories until a `package.json` can be found, reads it, and returns the user specified namespace or an empty object if not found.
+
+### pkgConf(namespace, [options])
+
+Returns a `Promise` for the config.
+
+### pkgConf.sync(namespace, [options])
+
+Returns the config.
+
+#### namespace
+
+Type: `string`
+
+The package.json namespace you want.
+
+#### options
+
+##### cwd
+
+Type: `string`<br>
+Default: `process.cwd()`
+
+Directory to start looking up for a package.json file.
+
+##### defaults
+
+Type: `Object`<br>
+
+Default config.
+
+##### skipOnFalse
+
+Type: `boolean`<br>
+Default: `false`
+
+Skip `package.json` files that have the namespaced config explicitly set to `false`.
+
+Continues searching upwards until the next `package.json` file is reached. This can be useful when you need to support the ability for users to have nested `package.json` files, but only read from the root one, like in the case of [`electron-builder`](https://github.com/electron-userland/electron-builder/wiki/Options#AppMetadata) where you have one `package.json` file for the app and one top-level for development.
+
+Example usage for the user:
+```json
+{
+ "name": "some-package",
+ "version": "1.0.0",
+ "unicorn": false
+}
+```
+
+### pkgConf.filepath(config)
+
+Pass in the `config` returned from any of the above methods.
+
+Returns the filepath to the package.json file or `null` when not found.
+
+
+## Related
+
+- [read-pkg-up](https://github.com/sindresorhus/read-pkg-up) - Read the closest package.json file
+- [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a package.json file
+- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)