diff options
Diffstat (limited to 'deps/node/deps/npm/node_modules/find-npm-prefix')
5 files changed, 0 insertions, 240 deletions
diff --git a/deps/node/deps/npm/node_modules/find-npm-prefix/LICENSE b/deps/node/deps/npm/node_modules/find-npm-prefix/LICENSE deleted file mode 100644 index 7953647e..00000000 --- a/deps/node/deps/npm/node_modules/find-npm-prefix/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright npm, Inc - -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/node/deps/npm/node_modules/find-npm-prefix/README.md b/deps/node/deps/npm/node_modules/find-npm-prefix/README.md deleted file mode 100644 index 77bf4b72..00000000 --- a/deps/node/deps/npm/node_modules/find-npm-prefix/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# find-npm-prefix - -Find the npm project directory associated with for a given directory - -## USAGE - -``` -const findPrefix = require('find-npm-prefix') - -findPrefix(process.cwd).then(prefix => { - … -}) -``` - -## findPrefix(dir) → Promise(prefix) - -This computes the npm prefix, that is, the directory that npm adds and -removes modules from for a given path. - -It takes a directory as an argument and returns a promise of the associated -prefix directory. - -## Algorithm - -1. If the directory is a `node_modules` folder, scan up the tree till you find a non-`node_modules` directory and return that. -2. Else, look for the first parent directory that contains a `node_modules` or a `package.json` - 1. If one is found, that's the prefix. - 2. If none are found, return the original directory we were given diff --git a/deps/node/deps/npm/node_modules/find-npm-prefix/find-prefix.js b/deps/node/deps/npm/node_modules/find-npm-prefix/find-prefix.js deleted file mode 100644 index d5e27132..00000000 --- a/deps/node/deps/npm/node_modules/find-npm-prefix/find-prefix.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict' -// try to find the most reasonable prefix to use - -module.exports = findPrefix - -const fs = require('fs') -const path = require('path') - -function findPrefix (dir) { - return new Promise((resolve, reject) => { - dir = path.resolve(dir) - - // this is a weird special case where an infinite recurse of - // node_modules folders resolves to the level that contains the - // very first node_modules folder - let walkedUp = false - while (path.basename(dir) === 'node_modules') { - dir = path.dirname(dir) - walkedUp = true - } - if (walkedUp) { - resolve(dir) - } else { - resolve(findPrefix_(dir)) - } - }) -} - -function findPrefix_ (dir, original) { - if (!original) original = dir - - const parent = path.dirname(dir) - // this is a platform independent way of checking if we're in the root - // directory - if (parent === dir) return Promise.resolve(original) - - return new Promise((resolve, reject) => { - fs.readdir(dir, (err, files) => { - if (err) { - // an error right away is a bad sign. - // unless the prefix was simply a non - // existent directory. - if (err && dir === original && err.code !== 'ENOENT') { - reject(err) - } else { - resolve(original) - } - } else if (files.indexOf('node_modules') !== -1 || - files.indexOf('package.json') !== -1) { - resolve(dir) - } else { - resolve(findPrefix_(parent, original)) - } - }) - }) -} diff --git a/deps/node/deps/npm/node_modules/find-npm-prefix/package.json b/deps/node/deps/npm/node_modules/find-npm-prefix/package.json deleted file mode 100644 index e9344afe..00000000 --- a/deps/node/deps/npm/node_modules/find-npm-prefix/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "_args": [ - [ - "find-npm-prefix@1.0.2", - "/Users/rebecca/code/npm" - ] - ], - "_from": "find-npm-prefix@1.0.2", - "_id": "find-npm-prefix@1.0.2", - "_inBundle": false, - "_integrity": "sha512-KEftzJ+H90x6pcKtdXZEPsQse8/y/UnvzRKrOSQFprnrGaFuJ62fVkP34Iu2IYuMvyauCyoLTNkJZgrrGA2wkA==", - "_location": "/find-npm-prefix", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "find-npm-prefix@1.0.2", - "name": "find-npm-prefix", - "escapedName": "find-npm-prefix", - "rawSpec": "1.0.2", - "saveSpec": null, - "fetchSpec": "1.0.2" - }, - "_requiredBy": [ - "/", - "/libcipm" - ], - "_resolved": "https://registry.npmjs.org/find-npm-prefix/-/find-npm-prefix-1.0.2.tgz", - "_spec": "1.0.2", - "_where": "/Users/rebecca/code/npm", - "author": { - "name": "Rebecca Turner", - "email": "me@re-becca.org", - "url": "http://re-becca.org/" - }, - "bugs": { - "url": "https://github.com/npm/find-npm-prefix/issues" - }, - "dependencies": {}, - "description": "Find the npm project directory associated with for a given directory", - "devDependencies": { - "require-inject": "^1.4.2", - "standard": "^10.0.3", - "tap": "^10.7.3" - }, - "directories": { - "test": "test" - }, - "homepage": "https://github.com/npm/find-npm-prefix#readme", - "keywords": [], - "license": "ISC", - "main": "find-prefix.js", - "name": "find-npm-prefix", - "repository": { - "type": "git", - "url": "git+https://github.com/npm/find-npm-prefix.git" - }, - "scripts": { - "test": "standard && tap --100 test" - }, - "version": "1.0.2" -} diff --git a/deps/node/deps/npm/node_modules/find-npm-prefix/test/find-prefix.js b/deps/node/deps/npm/node_modules/find-npm-prefix/test/find-prefix.js deleted file mode 100644 index de2ab41c..00000000 --- a/deps/node/deps/npm/node_modules/find-npm-prefix/test/find-prefix.js +++ /dev/null @@ -1,79 +0,0 @@ -'use strict' -const Bluebird = require('bluebird') -const test = require('tap').test -const requireInject = require('require-inject') -const findPrefix = requireInject('../find-prefix.js', { - fs: { - readdir: mockReaddir - } -}) - -test('find-prefix', t => { - const tests = { - '/Users/example/code/test1/node_modules': '/Users/example/code/test1', - '/Users/example/code/test1/node_modules/node_modules': '/Users/example/code/test1', - '/Users/example/code/test1/sub1': '/Users/example/code/test1', - '/Users/example/code/test1/sub1/sub1a': '/Users/example/code/test1', - '/Users/example/code/test2': '/Users/example/code/test2', - '/Users/example/code/test2/sub2': '/Users/example/code/test2', - '/Users/example/code': '/Users/example/code', - '/Users/example': '/Users/example', - '/does/not/exist': '/does/not/exist' - } - t.plan(Object.keys(tests).length) - return Bluebird.map(Object.keys(tests), dir => { - return findPrefix(dir).then(pre => { - t.is(pre, tests[dir], dir) - }) - }) -}) - -test('fail-prefix', t => { - return findPrefix('/Users/example/eperm').then(pre => { - t.fail('no eperm') - }).catch(err => { - t.is(err.code, 'EPERM', 'got perm error') - }) -}) - -const fixture = { - 'Users': { - 'example': { - 'code': { - 'test1': { - 'node_modules': { - 'node_modules': {} - }, - 'sub1': { - 'sub1a': {} - } - }, - 'test2': { - 'package.json': {}, - 'sub2': {} - } - } - } - } -} - -function mockReaddir (dir, cb) { - if (/eperm/.test(dir)) { - const err = new Error('Can not read: ' + dir) - err.code = 'EPERM' - return cb(err) - } - const parts = dir.split(/\//).slice(1) - let cwd = fixture - let part - while ((part = parts.shift())) { - if (part in cwd) { - cwd = cwd[part] - } else { - const err = new Error('Does not exist: ' + dir + ' * ' + part) - err.code = 'ENOENT' - return cb(err) - } - } - return cb(null, Object.keys(cwd)) -} |