aboutsummaryrefslogtreecommitdiff
path: root/node_modules/fined
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-10-10 03:43:44 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-10-10 03:43:44 +0200
commitabd94a7f5a50f43c797a11b53549ae48fff667c3 (patch)
treeab8ed457f65cdd72e13e0571d2975729428f1551 /node_modules/fined
parenta0247c6a3fd6a09a41a7e35a3441324c4dcb58be (diff)
add node_modules to address #4364
Diffstat (limited to 'node_modules/fined')
-rw-r--r--node_modules/fined/LICENSE21
-rw-r--r--node_modules/fined/README.md67
-rw-r--r--node_modules/fined/index.js159
-rw-r--r--node_modules/fined/package.json123
4 files changed, 370 insertions, 0 deletions
diff --git a/node_modules/fined/LICENSE b/node_modules/fined/LICENSE
new file mode 100644
index 000000000..3ca2d3f9a
--- /dev/null
+++ b/node_modules/fined/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Blaine Bublitz, Tyler Kellen and other contributors
+
+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/fined/README.md b/node_modules/fined/README.md
new file mode 100644
index 000000000..8788de09f
--- /dev/null
+++ b/node_modules/fined/README.md
@@ -0,0 +1,67 @@
+# Fined [![Build Status][travis-image]][travis-url] [![Build Status][appveyor-image]][appveyor-url]
+
+> Find a file given a declaration of locations
+
+[![NPM](https://nodei.co/npm/fined.png)](https://nodei.co/npm/fined/)
+
+## Usage
+
+```js
+var fined = require('fined');
+
+fined({ path: 'path/to/file', extensions: ['.js', '.json'] });
+// => { path: '/absolute/path/to/file.js', extension: '.js' } (if file exists)
+// => null (if file does not exist)
+
+var opts = {
+ name: '.app',
+ cwd: '.',
+ extensions: {
+ 'rc': 'default-rc-loader',
+ '.yml': 'default-yml-loader',
+ },
+};
+
+fined({ path: '.' }, opts);
+// => { path: '/absolute/of/cwd/.app.yml', extension: { '.yml': 'default-yml-loader' } }
+
+fined({ path: '~', extensions: { 'rc': 'some-special-rc-loader' } }, opts);
+// => { path: '/User/home/.apprc', extension: { 'rc': 'some-special-rc-loader' } }
+```
+
+## API
+
+### fined(pathObj, opts) => object | null
+
+#### Arguments:
+
+* **pathObj** [string | object] : a path setting for finding a file.
+* **opts** [object] : a plain object supplements `pathObj`.
+
+ `pathObj` and `opts` can have same properties:
+
+ * **path** [string] : a path string.
+ * **name** [string] : a basename.
+ * **extensions**: [string | array | object] : extensions.
+ * **cwd**: a base directory of `path` and for finding up.
+ * **findUp**: [boolean] : a flag to find up.
+
+#### Return:
+
+This function returns a plain object which consists of following properties if a file exists otherwise null.
+
+ * **path** : an absolute path
+ * **extension** : a string or a plain object of extension.
+
+
+## License
+
+MIT
+
+
+[npm-image]: http://img.shields.io/badge/npm-v0.0.0-blue.svg
+[npm-url]: https://www.npmjs.org/package/fined
+[travis-image]: https://travis-ci.org/js-cli/fined.svg?branch=master
+[travis-url]: https://travis-ci.org/js-cli/fined
+[appveyor-image]: https://ci.appveyor.com/api/projects/status/github/js-cli/fined?branch=master&svg=true
+[appveyor-url]: https://ci.appveyor.com/project/js-cli/fined
diff --git a/node_modules/fined/index.js b/node_modules/fined/index.js
new file mode 100644
index 000000000..fed7aae0b
--- /dev/null
+++ b/node_modules/fined/index.js
@@ -0,0 +1,159 @@
+'use strict';
+
+var fs = require('fs');
+var path = require('path');
+
+var isString = require('lodash.isstring');
+var isPlainObject = require('lodash.isplainobject');
+var isEmpty = require('lodash.isempty');
+var pick = require('lodash.pick');
+var assignWith = require('lodash.assignwith');
+
+var expandTilde = require('expand-tilde');
+var parsePath = require('parse-filepath');
+
+function assignNullish(objValue, srcValue) {
+ return (srcValue == null ? objValue : srcValue);
+}
+
+function defaults(mainObj, defaultObj) {
+ return assignWith({}, defaultObj, mainObj, assignNullish);
+}
+
+function fined(pathObj, defaultObj) {
+ var expandedPath = expandPath(pathObj, defaultObj);
+ return expandedPath ? findWithExpandedPath(expandedPath) : null;
+}
+
+function expandPath(pathObj, defaultObj) {
+ if (!isPlainObject(defaultObj)) {
+ defaultObj = {};
+ }
+
+ if (isString(pathObj)) {
+ pathObj = { path: pathObj };
+ }
+
+ if (!isPlainObject(pathObj)) {
+ pathObj = {};
+ }
+
+ pathObj = defaults(pathObj, defaultObj);
+
+ var filePath;
+ if (!isString(pathObj.path)) {
+ return null;
+ }
+ // Execution of toString is for a String object.
+ if (isString(pathObj.name) && pathObj.name) {
+ if (pathObj.path) {
+ filePath = expandTilde(pathObj.path.toString());
+ filePath = path.join(filePath, pathObj.name.toString());
+ } else {
+ filePath = pathObj.name.toString();
+ }
+ } else {
+ filePath = expandTilde(pathObj.path.toString());
+ }
+
+ var extArr = createExtensionArray(pathObj.extensions);
+ var extMap = createExtensionMap(pathObj.extensions);
+
+ var basedir = isString(pathObj.cwd) ? pathObj.cwd.toString() : '.';
+ basedir = path.resolve(expandTilde(basedir));
+
+ var findUp = !!pathObj.findUp;
+
+ var parsed = parsePath(filePath);
+ if (parsed.isAbsolute) {
+ filePath = filePath.slice(parsed.root.length);
+ findUp = false;
+ basedir = parsed.root;
+ } else if (parsed.root) { // Expanded path has a drive letter on Windows.
+ filePath = filePath.slice(parsed.root.length);
+ basedir = path.resolve(parsed.root);
+ }
+
+ return {
+ path: filePath,
+ basedir: basedir,
+ findUp: findUp,
+ extArr: extArr,
+ extMap: extMap,
+ };
+}
+
+function findWithExpandedPath(expanded) {
+ var found = expanded.findUp ?
+ findUpFile(expanded.basedir, expanded.path, expanded.extArr) :
+ findFile(expanded.basedir, expanded.path, expanded.extArr);
+
+ if (!found) {
+ return null;
+ }
+
+ if (expanded.extMap) {
+ found.extension = pick(expanded.extMap, found.extension);
+ }
+ return found;
+}
+
+function findFile(basedir, relpath, extArr) {
+ var noExtPath = path.resolve(basedir, relpath);
+ for (var i = 0, n = extArr.length; i < n; i++) {
+ var filepath = noExtPath + extArr[i];
+ try {
+ fs.statSync(filepath);
+ return { path: filepath, extension: extArr[i] };
+ } catch (e) {}
+ }
+
+ return null;
+}
+
+function findUpFile(basedir, filepath, extArr) {
+ var lastdir;
+ do {
+ var found = findFile(basedir, filepath, extArr);
+ if (found) {
+ return found;
+ }
+
+ lastdir = basedir;
+ basedir = path.dirname(basedir);
+ } while (lastdir !== basedir);
+
+ return null;
+}
+
+function createExtensionArray(exts) {
+ if (isString(exts)) {
+ return [exts];
+ }
+
+ if (Array.isArray(exts)) {
+ exts = exts.filter(isString);
+ return (exts.length > 0) ? exts : [''];
+ }
+
+ if (isPlainObject(exts)) {
+ exts = Object.keys(exts);
+ return (exts.length > 0) ? exts : [''];
+ }
+
+ return [''];
+}
+
+function createExtensionMap(exts) {
+ if (!isPlainObject(exts)) {
+ return null;
+ }
+
+ if (isEmpty(exts)) {
+ return { '': null };
+ }
+
+ return exts;
+}
+
+module.exports = fined;
diff --git a/node_modules/fined/package.json b/node_modules/fined/package.json
new file mode 100644
index 000000000..54b13588a
--- /dev/null
+++ b/node_modules/fined/package.json
@@ -0,0 +1,123 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "fined@^1.0.1",
+ "scope": null,
+ "escapedName": "fined",
+ "name": "fined",
+ "rawSpec": "^1.0.1",
+ "spec": ">=1.0.1 <2.0.0",
+ "type": "range"
+ },
+ "/home/dold/repos/taler/wallet-webex/node_modules/liftoff"
+ ]
+ ],
+ "_from": "fined@>=1.0.1 <2.0.0",
+ "_id": "fined@1.0.2",
+ "_inCache": true,
+ "_location": "/fined",
+ "_nodeVersion": "0.10.41",
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/fined-1.0.2.tgz_1475705448430_0.6886874639894813"
+ },
+ "_npmUser": {
+ "name": "phated",
+ "email": "blaine.bublitz@gmail.com"
+ },
+ "_npmVersion": "2.15.2",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "fined@^1.0.1",
+ "scope": null,
+ "escapedName": "fined",
+ "name": "fined",
+ "rawSpec": "^1.0.1",
+ "spec": ">=1.0.1 <2.0.0",
+ "type": "range"
+ },
+ "_requiredBy": [
+ "/liftoff"
+ ],
+ "_resolved": "https://registry.npmjs.org/fined/-/fined-1.0.2.tgz",
+ "_shasum": "5b28424b760d7598960b7ef8480dff8ad3660e97",
+ "_shrinkwrap": null,
+ "_spec": "fined@^1.0.1",
+ "_where": "/home/dold/repos/taler/wallet-webex/node_modules/liftoff",
+ "author": {
+ "name": "JS CLI Team",
+ "url": "https://github.com/js-cli"
+ },
+ "bugs": {
+ "url": "https://github.com/js-cli/fined/issues"
+ },
+ "contributors": [
+ {
+ "name": "Takayuki Sato",
+ "email": "t110000508260@yahoo.co.jp"
+ },
+ {
+ "name": "Blaine Bublitz",
+ "email": "blaine.bublitz@gmail.com"
+ }
+ ],
+ "dependencies": {
+ "expand-tilde": "^1.2.1",
+ "lodash.assignwith": "^4.0.7",
+ "lodash.isempty": "^4.2.1",
+ "lodash.isplainobject": "^4.0.4",
+ "lodash.isstring": "^4.0.1",
+ "lodash.pick": "^4.2.1",
+ "parse-filepath": "^1.0.1"
+ },
+ "description": "Find a file given a declaration of locations",
+ "devDependencies": {
+ "eslint": "^1.7.3",
+ "eslint-config-gulp": "^2.0.0",
+ "expect": "^1.19.0",
+ "istanbul": "^0.4.3",
+ "istanbul-coveralls": "^1.0.3",
+ "jscs": "^2.3.5",
+ "jscs-preset-gulp": "^1.0.0",
+ "mocha": "^2.4.5"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "5b28424b760d7598960b7ef8480dff8ad3660e97",
+ "tarball": "https://registry.npmjs.org/fined/-/fined-1.0.2.tgz"
+ },
+ "engines": {
+ "node": ">= 0.10"
+ },
+ "files": [
+ "index.js",
+ "LICENSE"
+ ],
+ "gitHead": "850b8dde2e520878a7ff62b9a6b4a45c82d19889",
+ "homepage": "https://github.com/js-cli/fined#readme",
+ "keywords": [],
+ "license": "MIT",
+ "main": "index.js",
+ "maintainers": [
+ {
+ "name": "phated",
+ "email": "blaine.bublitz@gmail.com"
+ }
+ ],
+ "name": "fined",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/js-cli/fined.git"
+ },
+ "scripts": {
+ "cover": "istanbul cover _mocha --report lcovonly",
+ "coveralls": "npm run cover && istanbul-coveralls",
+ "lint": "eslint . && jscs index.js test/",
+ "pretest": "npm run lint",
+ "test": "mocha --async-only"
+ },
+ "version": "1.0.2"
+}