diff options
Diffstat (limited to 'node_modules/glob2base')
-rwxr-xr-x | node_modules/glob2base/LICENSE | 20 | ||||
-rw-r--r-- | node_modules/glob2base/README.md | 51 | ||||
-rw-r--r-- | node_modules/glob2base/index.js | 59 | ||||
-rw-r--r-- | node_modules/glob2base/package.json | 106 |
4 files changed, 236 insertions, 0 deletions
diff --git a/node_modules/glob2base/LICENSE b/node_modules/glob2base/LICENSE new file mode 100755 index 000000000..7cbe012c6 --- /dev/null +++ b/node_modules/glob2base/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2014 Fractal <contact@wearefractal.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/glob2base/README.md b/node_modules/glob2base/README.md new file mode 100644 index 000000000..c14fa38c3 --- /dev/null +++ b/node_modules/glob2base/README.md @@ -0,0 +1,51 @@ +# glob2base [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Support us][gittip-image]][gittip-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] + + +## Information + +<table> +<tr> +<td>Package</td><td>glob2base</td> +</tr> +<tr> +<td>Description</td> +<td>Extracts a base path from a node-glob instance</td> +</tr> +<tr> +<td>Node Version</td> +<td>>= 0.10</td> +</tr> +</table> + +## Usage + +The module is a function that takes in a node-glob instance and returns a string. Basically it just gives you everything before any globbing/matching happens. + +```javascript +var glob2base = require('glob2base'); +var glob = require('glob'); + +// js/ +glob2base(new glob.Glob('js/**/*.js')); + +// css/test/ +glob2base(new glob.Glob('css/test/{a,b}/*.css')); + +// pages/whatever/ +glob2base(new glob.Glob('pages/whatever/index.html')); +``` + +## Like what we do? + +[gittip-url]: https://www.gittip.com/WeAreFractal/ +[gittip-image]: http://img.shields.io/gittip/WeAreFractal.svg + +[downloads-image]: http://img.shields.io/npm/dm/glob2base.svg +[npm-url]: https://npmjs.org/package/glob2base +[npm-image]: http://img.shields.io/npm/v/glob2base.svg + +[travis-url]: https://travis-ci.org/wearefractal/glob2base +[travis-image]: http://img.shields.io/travis/wearefractal/glob2base.svg + +[coveralls-url]: https://coveralls.io/r/wearefractal/glob2base +[coveralls-image]: http://img.shields.io/coveralls/wearefractal/glob2base/master.svg diff --git a/node_modules/glob2base/index.js b/node_modules/glob2base/index.js new file mode 100644 index 000000000..307e3f27c --- /dev/null +++ b/node_modules/glob2base/index.js @@ -0,0 +1,59 @@ +'use strict'; + +var path = require('path'); +var findIndex = require('find-index'); + +var flattenGlob = function(arr){ + var out = []; + var flat = true; + for(var i = 0; i < arr.length; i++) { + if (typeof arr[i] !== 'string') { + flat = false; + break; + } + out.push(arr[i]); + } + + // last one is a file or specific dir + // so we pop it off + if (flat) { + out.pop(); + } + return out; +}; + +var flattenExpansion = function(set) { + var first = set[0]; + var toCompare = set.slice(1); + + // find index where the diff is + var idx = findIndex(first, function(v, idx){ + if (typeof v !== 'string') { + return true; + } + + var matched = toCompare.every(function(arr){ + return v === arr[idx]; + }); + + return !matched; + }); + + return first.slice(0, idx); +}; + +var setToBase = function(set) { + // normal something/*.js + if (set.length <= 1) { + return flattenGlob(set[0]); + } + // has expansion + return flattenExpansion(set); +}; + +module.exports = function(glob) { + var set = glob.minimatch.set; + var baseParts = setToBase(set); + var basePath = path.normalize(baseParts.join(path.sep))+path.sep; + return basePath; +}; diff --git a/node_modules/glob2base/package.json b/node_modules/glob2base/package.json new file mode 100644 index 000000000..208cee85d --- /dev/null +++ b/node_modules/glob2base/package.json @@ -0,0 +1,106 @@ +{ + "_args": [ + [ + { + "raw": "glob2base@^0.0.12", + "scope": null, + "escapedName": "glob2base", + "name": "glob2base", + "rawSpec": "^0.0.12", + "spec": ">=0.0.12 <0.0.13", + "type": "range" + }, + "/home/dold/repos/taler/wallet-webex/node_modules/glob-stream" + ] + ], + "_from": "glob2base@>=0.0.12 <0.0.13", + "_id": "glob2base@0.0.12", + "_inCache": true, + "_location": "/glob2base", + "_nodeVersion": "0.10.33", + "_npmUser": { + "name": "fractal", + "email": "contact@wearefractal.com" + }, + "_npmVersion": "2.1.6", + "_phantomChildren": {}, + "_requested": { + "raw": "glob2base@^0.0.12", + "scope": null, + "escapedName": "glob2base", + "name": "glob2base", + "rawSpec": "^0.0.12", + "spec": ">=0.0.12 <0.0.13", + "type": "range" + }, + "_requiredBy": [ + "/glob-stream" + ], + "_resolved": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", + "_shasum": "9d419b3e28f12e83a362164a277055922c9c0d56", + "_shrinkwrap": null, + "_spec": "glob2base@^0.0.12", + "_where": "/home/dold/repos/taler/wallet-webex/node_modules/glob-stream", + "author": { + "name": "Fractal", + "email": "contact@wearefractal.com", + "url": "http://wearefractal.com/" + }, + "bugs": { + "url": "https://github.com/wearefractal/glob2base/issues" + }, + "dependencies": { + "find-index": "^0.1.1" + }, + "description": "Extracts a base path from a node-glob instance", + "devDependencies": { + "coveralls": "^2.6.1", + "glob": "^4.0.0", + "istanbul": "^0.3.2", + "jshint": "^2.4.1", + "jshint-stylish": "^1.0.0", + "mocha": "^2.0.0", + "mocha-lcov-reporter": "^0.0.1", + "should": "^4.0.0" + }, + "directories": {}, + "dist": { + "shasum": "9d419b3e28f12e83a362164a277055922c9c0d56", + "tarball": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz" + }, + "engines": { + "node": ">= 0.10" + }, + "files": [ + "index.js", + "lib" + ], + "gitHead": "d3fadacea415f4676fd431c90cd2205a2f1e6b26", + "homepage": "http://github.com/wearefractal/glob2base", + "licenses": [ + { + "type": "MIT", + "url": "http://github.com/wearefractal/glob2base/raw/master/LICENSE" + } + ], + "main": "./index.js", + "maintainers": [ + { + "name": "fractal", + "email": "contact@wearefractal.com" + } + ], + "name": "glob2base", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/wearefractal/glob2base.git" + }, + "scripts": { + "coveralls": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage", + "lint": "jshint index.js --reporter node_modules/jshint-stylish/stylish.js --exclude node_modules", + "test": "npm run-script lint && mocha --reporter spec" + }, + "version": "0.0.12" +} |