summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-cache-filename
diff options
context:
space:
mode:
authorTimothy J Fontaine <tjfontaine@gmail.com>2014-06-05 15:18:15 -0700
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-06-06 15:07:29 -0700
commitf051f317905b3b31945dfe965a492e54902e595f (patch)
tree06fedaefc3fc2dd5d6f197762afa4cd351659858 /deps/npm/node_modules/npm-cache-filename
parent535c7777ac674ba86cf93c44824e07b0e23ea8c4 (diff)
downloadnode-new-f051f317905b3b31945dfe965a492e54902e595f.tar.gz
npm: upgrade to v1.4.14
Diffstat (limited to 'deps/npm/node_modules/npm-cache-filename')
-rw-r--r--deps/npm/node_modules/npm-cache-filename/LICENSE15
-rw-r--r--deps/npm/node_modules/npm-cache-filename/README.md21
-rw-r--r--deps/npm/node_modules/npm-cache-filename/index.js20
-rw-r--r--deps/npm/node_modules/npm-cache-filename/package.json33
-rw-r--r--deps/npm/node_modules/npm-cache-filename/test.js21
5 files changed, 110 insertions, 0 deletions
diff --git a/deps/npm/node_modules/npm-cache-filename/LICENSE b/deps/npm/node_modules/npm-cache-filename/LICENSE
new file mode 100644
index 0000000000..20a4762540
--- /dev/null
+++ b/deps/npm/node_modules/npm-cache-filename/LICENSE
@@ -0,0 +1,15 @@
+The ISC License
+
+Copyright (c) npm, Inc. and Contributors
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/deps/npm/node_modules/npm-cache-filename/README.md b/deps/npm/node_modules/npm-cache-filename/README.md
new file mode 100644
index 0000000000..47bd08a494
--- /dev/null
+++ b/deps/npm/node_modules/npm-cache-filename/README.md
@@ -0,0 +1,21 @@
+# npm-cache-filename
+
+Given a cache folder and url, return the appropriate cache folder.
+
+## USAGE
+
+```javascript
+var cf = require('npm-cache-filename');
+console.log(cf('/tmp/cache', 'https://registry.npmjs.org:1234/foo/bar'));
+// outputs: /tmp/cache/registry.npmjs.org_1234/foo/bar
+```
+
+As a bonus, you can also bind it to a specific root path:
+
+```javascript
+var cf = require('npm-cache-filename');
+var getFile = cf('/tmp/cache');
+
+console.log(getFile('https://registry.npmjs.org:1234/foo/bar'));
+// outputs: /tmp/cache/registry.npmjs.org_1234/foo/bar
+```
diff --git a/deps/npm/node_modules/npm-cache-filename/index.js b/deps/npm/node_modules/npm-cache-filename/index.js
new file mode 100644
index 0000000000..9fd2488d40
--- /dev/null
+++ b/deps/npm/node_modules/npm-cache-filename/index.js
@@ -0,0 +1,20 @@
+var url = require('url');;
+var path = require('path');;
+
+module.exports = cf;;
+
+function cf(root, u) {
+ if (!u)
+ return cf.bind(null, root);;
+
+ u = url.parse(u);;
+ var h = u.host.replace(/:/g, '_');;
+ // Strip off any /-rev/... or ?rev=... bits
+ var revre = /(\?rev=|\?.*?&rev=|\/-rev\/).*$/
+ var parts = u.path.replace(revre, '').split('/').slice(1)
+ var p = [root, h].concat(parts.map(function(part) {
+ return encodeURIComponent(part).replace(/%/g, '_');;
+ }));;
+
+ return path.join.apply(path, p);;
+}
diff --git a/deps/npm/node_modules/npm-cache-filename/package.json b/deps/npm/node_modules/npm-cache-filename/package.json
new file mode 100644
index 0000000000..979450bc69
--- /dev/null
+++ b/deps/npm/node_modules/npm-cache-filename/package.json
@@ -0,0 +1,33 @@
+{
+ "name": "npm-cache-filename",
+ "version": "1.0.1",
+ "description": "Given a cache folder and url, return the appropriate cache folder.",
+ "main": "index.js",
+ "dependencies": {},
+ "devDependencies": {
+ "tap": "^0.4.10"
+ },
+ "scripts": {
+ "test": "tap test.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/npm/npm-cache-filename"
+ },
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/npm/npm-cache-filename/issues"
+ },
+ "homepage": "https://github.com/npm/npm-cache-filename",
+ "readme": "# npm-cache-filename\n\nGiven a cache folder and url, return the appropriate cache folder.\n\n## USAGE\n\n```javascript\nvar cf = require('npm-cache-filename');\nconsole.log(cf('/tmp/cache', 'https://registry.npmjs.org:1234/foo/bar'));\n// outputs: /tmp/cache/registry.npmjs.org_1234/foo/bar\n```\n\nAs a bonus, you can also bind it to a specific root path:\n\n```javascript\nvar cf = require('npm-cache-filename');\nvar getFile = cf('/tmp/cache');\n\nconsole.log(getFile('https://registry.npmjs.org:1234/foo/bar'));\n// outputs: /tmp/cache/registry.npmjs.org_1234/foo/bar\n```\n",
+ "readmeFilename": "README.md",
+ "_id": "npm-cache-filename@1.0.1",
+ "_shasum": "9b640f0c1a5ba1145659685372a9ff71f70c4323",
+ "_from": "npm-cache-filename@latest",
+ "_resolved": "https://registry.npmjs.org/npm-cache-filename/-/npm-cache-filename-1.0.1.tgz"
+}
diff --git a/deps/npm/node_modules/npm-cache-filename/test.js b/deps/npm/node_modules/npm-cache-filename/test.js
new file mode 100644
index 0000000000..5faecceb40
--- /dev/null
+++ b/deps/npm/node_modules/npm-cache-filename/test.js
@@ -0,0 +1,21 @@
+var test = require('tap').test;;
+test('it does the thing it says it does', function(t) {
+ var cf = require('./');;
+
+ t.equal(cf('/tmp/cache', 'https://foo:134/xyz?adf=foo:bar/baz'),
+ '/tmp/cache/foo_134/xyz_3Fadf_3Dfoo_3Abar/baz');;
+
+ var getFile = cf('/tmp/cache');;
+ t.equal(getFile('https://foo:134/xyz?adf=foo:bar/baz'),
+ '/tmp/cache/foo_134/xyz_3Fadf_3Dfoo_3Abar/baz');;
+
+ t.equal(cf("/tmp", "https://foo:134/xyz/-rev/baz"),
+ '/tmp/foo_134/xyz')
+ t.equal(cf("/tmp", "https://foo:134/xyz/?rev=baz"),
+ '/tmp/foo_134/xyz')
+ t.equal(cf("/tmp", "https://foo:134/xyz/?foo&rev=baz"),
+ '/tmp/foo_134/xyz')
+ t.equal(cf("/tmp", "https://foo:134/xyz-rev/baz"),
+ '/tmp/foo_134/xyz-rev/baz')
+ t.end();
+});;