summaryrefslogtreecommitdiff
path: root/deps/npm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib')
-rw-r--r--deps/npm/lib/cache.js29
-rw-r--r--deps/npm/lib/install.js153
-rw-r--r--deps/npm/lib/outdated.js12
-rw-r--r--deps/npm/lib/repo.js2
-rw-r--r--deps/npm/lib/utils/error-handler.js2
5 files changed, 46 insertions, 152 deletions
diff --git a/deps/npm/lib/cache.js b/deps/npm/lib/cache.js
index c182817e4f..cc45460833 100644
--- a/deps/npm/lib/cache.js
+++ b/deps/npm/lib/cache.js
@@ -21,8 +21,8 @@ cache folders:
1. urls: http!/server.com/path/to/thing
2. c:\path\to\thing: file!/c!/path/to/thing
3. /path/to/thing: file!/path/to/thing
-4. git@ private: git_github.com!isaacs/npm
-5. git://public: git!/github.com/isaacs/npm
+4. git@ private: git_github.com!npm/npm
+5. git://public: git!/github.com/npm/npm
6. git+blah:// git-blah!/server.com/foo/bar
adding a folder:
@@ -508,9 +508,30 @@ function archiveGitRemote (p, u, co, origUrl, cb) {
}
log.verbose("git fetch -a origin ("+u+")", stdout)
tmp = path.join(npm.tmp, Date.now()+"-"+Math.random(), "tmp.tgz")
- resolveHead()
+ verifyOwnership()
})
+ function verifyOwnership() {
+ if (process.platform === "win32") {
+ log.silly("verifyOwnership", "skipping for windows")
+ resolveHead()
+ } else {
+ getCacheStat(function(er, cs) {
+ if (er) {
+ log.error("Could not get cache stat")
+ return cb(er)
+ }
+ chownr(p, cs.uid, cs.gid, function(er) {
+ if (er) {
+ log.error("Failed to change folder ownership under npm cache for %s", p)
+ return cb(er)
+ }
+ resolveHead()
+ })
+ })
+ }
+ }
+
function resolveHead () {
exec(git, resolve, {cwd: p, env: env}, function (er, stdout, stderr) {
stdout = (stdout + "\n" + stderr).trim()
@@ -523,7 +544,7 @@ function archiveGitRemote (p, u, co, origUrl, cb) {
parsed.hash = stdout
resolved = url.format(parsed)
- // https://github.com/isaacs/npm/issues/3224
+ // https://github.com/npm/npm/issues/3224
// node incorrectly sticks a / at the start of the path
// We know that the host won't change, so split and detect this
var spo = origUrl.split(parsed.host)
diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js
index 9270303a65..f0604a9ce1 100644
--- a/deps/npm/lib/install.js
+++ b/deps/npm/lib/install.js
@@ -73,6 +73,7 @@ var npm = require("./npm.js")
, lifecycle = require("./utils/lifecycle.js")
, archy = require("archy")
, isGitUrl = require("./utils/is-git-url.js")
+ , npmInstallChecks = require("npm-install-checks")
function install (args, cb_) {
var hasArguments = !!args.length
@@ -842,12 +843,16 @@ function installOne_ (target, where, context, cb) {
}
installOnesInProgress[target.name].push(where)
var indexOfIOIP = installOnesInProgress[target.name].length - 1
+ , force = npm.config.get("force")
+ , nodeVersion = npm.config.get("node-version")
+ , strict = npm.config.get("engine-strict")
+ , c = npmInstallChecks
chain
- ( [ [checkEngine, target]
- , [checkPlatform, target]
- , [checkCycle, target, context.ancestors]
- , [checkGit, targetFolder]
+ ( [ [c.checkEngine, target, npm.version, nodeVersion, force, strict]
+ , [c.checkPlatform, target, force]
+ , [c.checkCycle, target, context.ancestors]
+ , [c.checkGit, targetFolder]
, [write, target, targetFolder, context] ]
, function (er, d) {
installOnesInProgress[target.name].splice(indexOfIOIP, 1)
@@ -860,146 +865,6 @@ function installOne_ (target, where, context, cb) {
)
}
-function checkEngine (target, cb) {
- var npmv = npm.version
- , force = npm.config.get("force")
- , nodev = force ? null : npm.config.get("node-version")
- , strict = npm.config.get("engine-strict") || target.engineStrict
- , eng = target.engines
- if (!eng) return cb()
- if (nodev && eng.node && !semver.satisfies(nodev, eng.node)
- || eng.npm && !semver.satisfies(npmv, eng.npm)) {
- if (strict) {
- var er = new Error("Unsupported")
- er.code = "ENOTSUP"
- er.required = eng
- er.pkgid = target._id
- return cb(er)
- } else {
- log.warn( "engine", "%s: wanted: %j (current: %j)"
- , target._id, eng, {node: nodev, npm: npm.version} )
- }
- }
- return cb()
-}
-
-function checkPlatform (target, cb) {
- var platform = process.platform
- , arch = process.arch
- , osOk = true
- , cpuOk = true
- , force = npm.config.get("force")
-
- if (force) {
- return cb()
- }
-
- if (target.os) {
- osOk = checkList(platform, target.os)
- }
- if (target.cpu) {
- cpuOk = checkList(arch, target.cpu)
- }
- if (!osOk || !cpuOk) {
- var er = new Error("Unsupported")
- er.code = "EBADPLATFORM"
- er.os = target.os || ['any']
- er.cpu = target.cpu || ['any']
- er.pkgid = target._id
- return cb(er)
- }
- return cb()
-}
-
-function checkList (value, list) {
- var tmp
- , match = false
- , blc = 0
- if (typeof list === "string") {
- list = [list]
- }
- if (list.length === 1 && list[0] === "any") {
- return true
- }
- for (var i = 0; i < list.length; ++i) {
- tmp = list[i]
- if (tmp[0] === '!') {
- tmp = tmp.slice(1)
- if (tmp === value) {
- return false
- }
- ++blc
- } else {
- match = match || tmp === value
- }
- }
- return match || blc === list.length
-}
-
-function checkCycle (target, ancestors, cb) {
- // there are some very rare and pathological edge-cases where
- // a cycle can cause npm to try to install a never-ending tree
- // of stuff.
- // Simplest:
- //
- // A -> B -> A' -> B' -> A -> B -> A' -> B' -> A -> ...
- //
- // Solution: Simply flat-out refuse to install any name@version
- // that is already in the prototype tree of the ancestors object.
- // A more correct, but more complex, solution would be to symlink
- // the deeper thing into the new location.
- // Will do that if anyone whines about this irl.
- //
- // Note: `npm install foo` inside of the `foo` package will abort
- // earlier if `--force` is not set. However, if it IS set, then
- // we need to still fail here, but just skip the first level. Of
- // course, it'll still fail eventually if it's a true cycle, and
- // leave things in an undefined state, but that's what is to be
- // expected when `--force` is used. That is why getPrototypeOf
- // is used *twice* here: to skip the first level of repetition.
-
- var p = Object.getPrototypeOf(Object.getPrototypeOf(ancestors))
- , name = target.name
- , version = target.version
- while (p && p !== Object.prototype && p[name] !== version) {
- p = Object.getPrototypeOf(p)
- }
- if (p[name] !== version) return cb()
-
- var er = new Error("Unresolvable cycle detected")
- var tree = [target._id, JSON.parse(JSON.stringify(ancestors))]
- , t = Object.getPrototypeOf(ancestors)
- while (t && t !== Object.prototype) {
- if (t === p) t.THIS_IS_P = true
- tree.push(JSON.parse(JSON.stringify(t)))
- t = Object.getPrototypeOf(t)
- }
- log.verbose("unresolvable dependency tree", tree)
- er.pkgid = target._id
- er.code = "ECYCLE"
- return cb(er)
-}
-
-function checkGit (folder, cb) {
- // if it's a git repo then don't touch it!
- fs.lstat(folder, function (er, s) {
- if (er || !s.isDirectory()) return cb()
- else checkGit_(folder, cb)
- })
-}
-
-function checkGit_ (folder, cb) {
- fs.stat(path.resolve(folder, ".git"), function (er, s) {
- if (!er && s.isDirectory()) {
- var e = new Error("Appears to be a git repo or submodule.")
- e.path = folder
- e.code = "EISGIT"
- return cb(e)
- }
- cb()
- })
-}
-
function write (target, targetFolder, context, cb_) {
var up = npm.config.get("unsafe-perm")
, user = up ? null : npm.config.get("user")
diff --git a/deps/npm/lib/outdated.js b/deps/npm/lib/outdated.js
index b94b0c6a34..5eb49737ff 100644
--- a/deps/npm/lib/outdated.js
+++ b/deps/npm/lib/outdated.js
@@ -199,7 +199,9 @@ function shouldUpdate (args, dir, dep, has, req, depth, cb) {
// { version: , from: }
var curr = has[dep]
- function skip () {
+ function skip (er) {
+ // show user that no viable version can be found
+ if (er) return cb(er)
outdated_( args
, path.resolve(dir, "node_modules", dep)
, has
@@ -226,7 +228,13 @@ function shouldUpdate (args, dir, dep, has, req, depth, cb) {
cache.add(dep, req, function (er, d) {
// if this fails, then it means we can't update this thing.
// it's probably a thing that isn't published.
- if (er) return skip()
+ if (er) {
+ if (er.code && er.code === 'ETARGET') {
+ // no viable version found
+ return skip(er)
+ }
+ return skip()
+ }
// check that the url origin hasn't changed (#1727) and that
// there is no newer version available
diff --git a/deps/npm/lib/repo.js b/deps/npm/lib/repo.js
index ed1f7e1dc9..b95bd7562f 100644
--- a/deps/npm/lib/repo.js
+++ b/deps/npm/lib/repo.js
@@ -37,7 +37,7 @@ function getUrlAndOpen (d, cb) {
var r = d.repository;
if (!r) return cb(new Error('no repository'));
// XXX remove this when npm@v1.3.10 from node 0.10 is deprecated
- // from https://github.com/isaacs/npm-www/issues/418
+ // from https://github.com/npm/npm-www/issues/418
if (githubUserRepo(r.url))
r.url = githubUserRepo(r.url)
var url = github(r.url)
diff --git a/deps/npm/lib/utils/error-handler.js b/deps/npm/lib/utils/error-handler.js
index 93d8792e98..4286a1c291 100644
--- a/deps/npm/lib/utils/error-handler.js
+++ b/deps/npm/lib/utils/error-handler.js
@@ -270,7 +270,7 @@ function errorHandler (er) {
log.error("", er.stack || er.message || er)
log.error("", ["If you need help, you may report this *entire* log,"
,"including the npm and node versions, at:"
- ," <http://github.com/isaacs/npm/issues>"
+ ," <http://github.com/npm/npm/issues>"
].join("\n"))
printStack = false
break