summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/find-npm-prefix
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/find-npm-prefix')
-rw-r--r--deps/npm/node_modules/find-npm-prefix/find-prefix.js50
-rw-r--r--deps/npm/node_modules/find-npm-prefix/package.json22
2 files changed, 35 insertions, 37 deletions
diff --git a/deps/npm/node_modules/find-npm-prefix/find-prefix.js b/deps/npm/node_modules/find-npm-prefix/find-prefix.js
index d5e271322b..089572ec11 100644
--- a/deps/npm/node_modules/find-npm-prefix/find-prefix.js
+++ b/deps/npm/node_modules/find-npm-prefix/find-prefix.js
@@ -5,9 +5,11 @@ module.exports = findPrefix
const fs = require('fs')
const path = require('path')
+const Bluebird = require('bluebird')
+const readdir = Bluebird.promisify(fs.readdir)
function findPrefix (dir) {
- return new Promise((resolve, reject) => {
+ return Bluebird.try(() => {
dir = path.resolve(dir)
// this is a weird special case where an infinite recurse of
@@ -18,11 +20,9 @@ function findPrefix (dir) {
dir = path.dirname(dir)
walkedUp = true
}
- if (walkedUp) {
- resolve(dir)
- } else {
- resolve(findPrefix_(dir))
- }
+ if (walkedUp) return dir
+
+ return findPrefix_(dir)
})
}
@@ -32,25 +32,23 @@ function findPrefix_ (dir, original) {
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))
- }
- })
+ if (parent === dir) return original
+
+ return readdir(dir).then(files => {
+ if (files.indexOf('node_modules') !== -1 ||
+ files.indexOf('package.json') !== -1) {
+ return dir
+ }
+
+ return findPrefix_(parent, original)
+ }, er => {
+ // an error right away is a bad sign.
+ // unless the prefix was simply a non
+ // existent directory.
+ if (er && dir === original && er.code !== 'ENOENT') {
+ throw er
+ } else {
+ return original
+ }
})
}
diff --git a/deps/npm/node_modules/find-npm-prefix/package.json b/deps/npm/node_modules/find-npm-prefix/package.json
index 628eee218b..4007b90c3c 100644
--- a/deps/npm/node_modules/find-npm-prefix/package.json
+++ b/deps/npm/node_modules/find-npm-prefix/package.json
@@ -1,27 +1,27 @@
{
- "_from": "find-npm-prefix@1.0.2",
- "_id": "find-npm-prefix@1.0.2",
+ "_from": "find-npm-prefix@latest",
+ "_id": "find-npm-prefix@1.0.1",
"_inBundle": false,
- "_integrity": "sha512-KEftzJ+H90x6pcKtdXZEPsQse8/y/UnvzRKrOSQFprnrGaFuJ62fVkP34Iu2IYuMvyauCyoLTNkJZgrrGA2wkA==",
+ "_integrity": "sha512-I9R7ZnsjlKRvXBJjA1PE4wAkSc24YChoomWdEPTZgeB4DHxf87OutNGV5McFj6WwPghH97nZRejH58XvY6ga6Q==",
"_location": "/find-npm-prefix",
"_phantomChildren": {},
"_requested": {
- "type": "version",
+ "type": "tag",
"registry": true,
- "raw": "find-npm-prefix@1.0.2",
+ "raw": "find-npm-prefix@latest",
"name": "find-npm-prefix",
"escapedName": "find-npm-prefix",
- "rawSpec": "1.0.2",
+ "rawSpec": "latest",
"saveSpec": null,
- "fetchSpec": "1.0.2"
+ "fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
- "_resolved": "https://registry.npmjs.org/find-npm-prefix/-/find-npm-prefix-1.0.2.tgz",
- "_shasum": "8d8ce2c78b3b4b9e66c8acc6a37c231eb841cfdf",
- "_spec": "find-npm-prefix@1.0.2",
+ "_resolved": "https://registry.npmjs.org/find-npm-prefix/-/find-npm-prefix-1.0.1.tgz",
+ "_shasum": "af0faa74e19294b3c8634bae0e91017bb5adfac2",
+ "_spec": "find-npm-prefix@latest",
"_where": "/Users/rebecca/code/npm",
"author": {
"name": "Rebecca Turner",
@@ -55,5 +55,5 @@
"scripts": {
"test": "standard && tap --100 test"
},
- "version": "1.0.2"
+ "version": "1.0.1"
}