diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
commit | abd94a7f5a50f43c797a11b53549ae48fff667c3 (patch) | |
tree | ab8ed457f65cdd72e13e0571d2975729428f1551 /node_modules/findup-sync | |
parent | a0247c6a3fd6a09a41a7e35a3441324c4dcb58be (diff) | |
download | wallet-core-abd94a7f5a50f43c797a11b53549ae48fff667c3.tar.xz |
add node_modules to address #4364
Diffstat (limited to 'node_modules/findup-sync')
-rw-r--r-- | node_modules/findup-sync/index.js | 99 | ||||
-rw-r--r-- | node_modules/findup-sync/package.json | 124 |
2 files changed, 223 insertions, 0 deletions
diff --git a/node_modules/findup-sync/index.js b/node_modules/findup-sync/index.js new file mode 100644 index 000000000..1707660ef --- /dev/null +++ b/node_modules/findup-sync/index.js @@ -0,0 +1,99 @@ +'use strict'; + +/** + * Module dependencies + */ + +var fs = require('fs'); +var path = require('path'); +var isGlob = require('is-glob'); +var resolveDir = require('resolve-dir'); +var detect = require('detect-file'); +var mm = require('micromatch'); + +/** + * @param {String|Array} `pattern` Glob pattern or file path(s) to match against. + * @param {Object} `options` Options to pass to [micromatch]. Note that if you want to start in a different directory than the current working directory, specify the `options.cwd` property here. + * @return {String} Returns the first matching file. + * @api public + */ + +module.exports = function(patterns, options) { + if (typeof patterns === 'string') { + return lookup(patterns, options); + } + + if (!Array.isArray(patterns)) { + throw new TypeError('findup-sync expects a string or array as the first argument.'); + } + + var len = patterns.length; + var idx = -1; + + while (++idx < len) { + var res = lookup(patterns[idx], options); + if (res) { + return res; + } + } + + return null; +}; + +function lookup(pattern, options) { + options = options || {}; + var cwd = path.resolve(resolveDir(options.cwd || '')); + if (isGlob(pattern)) { + return matchFile(cwd, pattern, options); + } else { + return findFile(cwd, pattern, options); + } +} + +function matchFile(cwd, pattern, opts) { + var isMatch = mm.matcher(pattern, opts); + var files = tryReaddirSync(cwd); + var len = files.length; + var idx = -1; + + while (++idx < len) { + var name = files[idx]; + var fp = path.join(cwd, name); + if (isMatch(name) || isMatch(fp)) { + return fp; + } + } + + var dir = path.dirname(cwd); + if (dir === cwd) { + return null; + } + return matchFile(dir, pattern, opts); +} + +function findFile(cwd, filename, options) { + var res; + var fp = cwd ? path.resolve(cwd, filename) : filename; + if (res = detect(fp, options)) { + return res; + } + + var segs = cwd.split(path.sep); + var len = segs.length; + + while (len--) { + cwd = segs.slice(0, len).join(path.sep); + fp = path.resolve(cwd, filename); + if (res = detect(fp, options)) { + return res; + } + } + return null; +} + +function tryReaddirSync(fp) { + try { + return fs.readdirSync(fp); + } catch(err) {} + return []; +} diff --git a/node_modules/findup-sync/package.json b/node_modules/findup-sync/package.json new file mode 100644 index 000000000..4826463c7 --- /dev/null +++ b/node_modules/findup-sync/package.json @@ -0,0 +1,124 @@ +{ + "_args": [ + [ + { + "raw": "findup-sync@^0.4.2", + "scope": null, + "escapedName": "findup-sync", + "name": "findup-sync", + "rawSpec": "^0.4.2", + "spec": ">=0.4.2 <0.5.0", + "type": "range" + }, + "/home/dold/repos/taler/wallet-webex/node_modules/liftoff" + ] + ], + "_from": "findup-sync@>=0.4.2 <0.5.0", + "_id": "findup-sync@0.4.2", + "_inCache": true, + "_location": "/findup-sync", + "_nodeVersion": "6.2.0", + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/findup-sync-0.4.2.tgz_1468194510974_0.19327558996155858" + }, + "_npmUser": { + "name": "jonschlinkert", + "email": "github@sellside.com" + }, + "_npmVersion": "3.8.9", + "_phantomChildren": {}, + "_requested": { + "raw": "findup-sync@^0.4.2", + "scope": null, + "escapedName": "findup-sync", + "name": "findup-sync", + "rawSpec": "^0.4.2", + "spec": ">=0.4.2 <0.5.0", + "type": "range" + }, + "_requiredBy": [ + "/liftoff" + ], + "_resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.4.2.tgz", + "_shasum": "a8117d0f73124f5a4546839579fe52d7129fb5e5", + "_shrinkwrap": null, + "_spec": "findup-sync@^0.4.2", + "_where": "/home/dold/repos/taler/wallet-webex/node_modules/liftoff", + "author": { + "name": "\"Cowboy\" Ben Alman", + "url": "http://benalman.com" + }, + "bugs": { + "url": "https://github.com/cowboy/node-findup-sync/issues" + }, + "dependencies": { + "detect-file": "^0.1.0", + "is-glob": "^2.0.1", + "micromatch": "^2.3.7", + "resolve-dir": "^0.1.0" + }, + "description": "Find the first file matching a given pattern in the current directory or the nearest ancestor directory.", + "devDependencies": { + "fs-exists-sync": "^0.1.0", + "grunt": "^1.0.1", + "grunt-contrib-jshint": "^0.12.0", + "is-absolute": "^0.2.3", + "minimist": "^1.2.0", + "mocha": "^2.4.5", + "normalize-path": "^2.0.1", + "os-homedir": "^1.0.1", + "resolve": "^1.1.7" + }, + "directories": {}, + "dist": { + "shasum": "a8117d0f73124f5a4546839579fe52d7129fb5e5", + "tarball": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.4.2.tgz" + }, + "engines": { + "node": ">= 0.8.0" + }, + "files": [ + "index.js" + ], + "gitHead": "3515969ca312d2b24fc66397dac1a0a4ce9b4aaa", + "homepage": "https://github.com/cowboy/node-findup-sync", + "keywords": [ + "file", + "find", + "find-up", + "findup", + "glob", + "match", + "pattern", + "resolve", + "search" + ], + "license": "MIT", + "main": "index.js", + "maintainers": [ + { + "name": "cowboy", + "email": "cowboy@rj3.net" + }, + { + "name": "jonschlinkert", + "email": "github@sellside.com" + }, + { + "name": "tkellen", + "email": "tyler@sleekcode.net" + } + ], + "name": "findup-sync", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/cowboy/node-findup-sync.git" + }, + "scripts": { + "test": "grunt && mocha" + }, + "version": "0.4.2" +} |