diff options
author | isaacs <i@izs.me> | 2012-06-04 17:32:46 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-06-04 17:32:59 -0700 |
commit | b9e40fbaacc60de562481b764b0e78bf021f7cfa (patch) | |
tree | 0ff91950f15fc6e40ddaccee7c6487f6240aa96b /deps/npm/lib | |
parent | cc36cc5999937aeb0ed00f82b5c969edecaa1b1d (diff) | |
download | node-b9e40fbaacc60de562481b764b0e78bf021f7cfa.tar.gz |
Upgrade npm to 1.1.24
Diffstat (limited to 'deps/npm/lib')
-rw-r--r-- | deps/npm/lib/bugs.js | 24 | ||||
-rw-r--r-- | deps/npm/lib/cache.js | 11 | ||||
-rw-r--r-- | deps/npm/lib/docs.js | 24 | ||||
-rw-r--r-- | deps/npm/lib/install.js | 2 | ||||
-rw-r--r-- | deps/npm/lib/utils/error-handler.js | 53 |
5 files changed, 82 insertions, 32 deletions
diff --git a/deps/npm/lib/bugs.js b/deps/npm/lib/bugs.js index 7982746cf..2a9352632 100644 --- a/deps/npm/lib/bugs.js +++ b/deps/npm/lib/bugs.js @@ -41,10 +41,22 @@ function bugs (args, cb) { } function open (url, cb) { - exec(npm.config.get("browser"), [url], log.er(cb, - "Failed to open "+url+" in a browser. It could be that the\n"+ - "'browser' config is not set. Try doing this:\n"+ - " npm config set browser google-chrome\n"+ - "or:\n"+ - " npm config set browser lynx\n")) + var args = [url] + , browser = npm.config.get("browser") + + if (process.platform === "win32" && browser === "start") { + args = [ "/c", "start" ].concat(args) + browser = "cmd" + } + + if (!browser) { + var er = ["the 'browser' config is not set. Try doing this:" + ," npm config set browser google-chrome" + ,"or:" + ," npm config set browser lynx"].join("\n") + return cb(er) + } + + exec(browser, args, process.env, false, function () {}) + cb() } diff --git a/deps/npm/lib/cache.js b/deps/npm/lib/cache.js index 706d7f883..076267e89 100644 --- a/deps/npm/lib/cache.js +++ b/deps/npm/lib/cache.js @@ -296,8 +296,19 @@ function addRemoteGit (u, parsed, name, cb_) { // figure out what we should check out. var co = parsed.hash && parsed.hash.substr(1) || "master" + // git is so tricky! + // if the path is like ssh://foo:22/some/path then it works, but + // it needs the ssh:// + // If the path is like ssh://foo:some/path then it works, but + // only if you remove the ssh:// u = u.replace(/^git\+/, "") .replace(/#.*$/, "") + + // ssh paths that are scp-style urls don't need the ssh:// + if (parsed.pathname.match(/^\/?:/)) { + u = u.replace(/^ssh:\/\//, "") + } + log.verbose([u, co], "addRemoteGit") var tmp = path.join(npm.tmp, Date.now()+"-"+Math.random()) diff --git a/deps/npm/lib/docs.js b/deps/npm/lib/docs.js index 8af4c1bb6..20b110406 100644 --- a/deps/npm/lib/docs.js +++ b/deps/npm/lib/docs.js @@ -37,10 +37,22 @@ function docs (args, cb) { } function open (url, cb) { - exec(npm.config.get("browser"), [url], log.er(cb, - "Failed to open "+url+" in a browser. It could be that the\n"+ - "'browser' config is not set. Try doing this:\n"+ - " npm config set browser google-chrome\n"+ - "or:\n"+ - " npm config set browser lynx\n")) + var args = [url] + , browser = npm.config.get("browser") + + if (process.platform === "win32" && browser === "start") { + args = [ "/c", "start" ].concat(args) + browser = "cmd" + } + + if (!browser) { + var er = ["the 'browser' config is not set. Try doing this:" + ," npm config set browser google-chrome" + ,"or:" + ," npm config set browser lynx"].join("\n") + return cb(er) + } + + exec(browser, args, process.env, false, function () {}) + cb() } diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js index 5873ca968..276f3d8b3 100644 --- a/deps/npm/lib/install.js +++ b/deps/npm/lib/install.js @@ -606,7 +606,7 @@ function installOne (target, where, context, cb) { function localLink (target, where, context, cb) { log.verbose(target._id, "try to link") - var jsonFile = path.resolve( npm.dir, target.name + var jsonFile = path.resolve( npm.globalDir, target.name , "package.json" ) , parent = context.parent diff --git a/deps/npm/lib/utils/error-handler.js b/deps/npm/lib/utils/error-handler.js index 0cdc03fac..f7fdf165f 100644 --- a/deps/npm/lib/utils/error-handler.js +++ b/deps/npm/lib/utils/error-handler.js @@ -10,13 +10,14 @@ var cbCalled = false , path = require("path") , ini = require("./ini.js") , wroteLogFile = false + , exitCode = 0 process.on("exit", function (code) { // console.error("exit", code) if (!ini.resolved) return if (code) itWorked = false - if (itWorked) log("ok") + if (itWorked) log.info("ok") else { if (!cbCalled) { log.error("cb() never called!\n ") @@ -30,9 +31,40 @@ process.on("exit", function (code) { } log.win("not ok") } - itWorked = false // ready for next exit + + var doExit = npm.config.get("_exit") + if (doExit) { + // actually exit. + if (exitCode === 0 && !itWorked) { + exitCode = 1 + } + if (exitCode !== 0) process.exit(exitCode) + } else { + itWorked = false // ready for next exit + } }) +function exit (code, noLog) { + exitCode = exitCode || code + + var doExit = npm.config.get("_exit") + log.verbose([code, doExit], "exit") + if (log.level === log.LEVEL.silent) noLog = true + + if (code && !noLog) writeLogFile(reallyExit) + else rm("npm-debug.log", function () { rm(npm.tmp, reallyExit) }) + + function reallyExit() { + itWorked = !code + + // just emit a fake exit event. + // if we're really exiting, then let it exit on its own, so that + // in-process stuff can finish or clean up first. + if (!doExit) process.emit("exit", code) + } +} + + function errorHandler (er) { // console.error("errorHandler", er) if (!ini.resolved) { @@ -222,23 +254,6 @@ function errorHandler (er) { exit(typeof er.errno === "number" ? er.errno : 1) } -function exit (code, noLog) { - var doExit = npm.config.get("_exit") - log.verbose([code, doExit], "exit") - if (log.level === log.LEVEL.silent) noLog = true - - if (code && !noLog) writeLogFile(reallyExit) - else rm("npm-debug.log", function () { rm(npm.tmp, reallyExit) }) - - function reallyExit() { - itWorked = !code - //if (!itWorked) { - if (!doExit) process.emit("exit", code) - else process.exit(code) - //} - } -} - var writingLogFile = false function writeLogFile (cb) { if (writingLogFile) return cb() |