Permalink
Browse files

Merge remote branch 'upstream/master'

  • Loading branch information...
vvision committed Nov 7, 2012
2 parents 722402d + f4d0b35 commit a4ea3de8d44eda4e57f8e74418329999bed392ed
View
@@ -77,3 +77,4 @@ Nicolas Morel <marsup@gmail.com>
Mark Dube <markisdee@gmail.com>
Maxim Bogushevich <boga1@mail.ru>
Justin Beckwith <justbe@microsoft.com>
+Meaglin <Meaglin.wasabi@gmail.com>
View
@@ -10,6 +10,8 @@ designed to reduce visual clutter and make bugs more apparent.
If you want to contribute to npm (which is very encouraged), you should
make your code conform to npm's style.
+Note: this concerns npm's code not the specific packages at npmjs.org
+
## Line Length
Keep lines shorter than 80 characters. It's better for lines to be
View
@@ -112,7 +112,6 @@ The following shorthands are parsed on the command-line:
* `-reg`: `--registry`
* `-v`: `--version`
* `-f`: `--force`
-* `-l`: `--long`
* `-desc`: `--description`
* `-S`: `--save`
* `-D`: `--save-dev`
View
@@ -474,10 +474,20 @@ function addNameTag (name, tag, data, cb) {
if (!explicit && Object.keys(data.versions).length) {
return addNamed(name, "*", data, cb)
}
- return cb(installTargetsError(tag, data))
+
+ er = installTargetsError(tag, data)
+
+ // might be username/project
+ // in that case, try it as a github url.
+ if (tag.split("/").length === 2) {
+ return maybeGithub(tag, name, er, cb)
+ }
+
+ return cb(er)
})
}
+
function engineFilter (data) {
var npmv = npm.version
, nodev = npm.config.get("node-version")
@@ -639,13 +649,30 @@ function addLocal (p, name, cb_) {
if (er) return cb(er)
// figure out if this is a folder or file.
fs.stat(p, function (er, s) {
- if (er) return cb(er)
+ if (er) {
+ // might be username/project
+ // in that case, try it as a github url.
+ if (p.split("/").length === 2) {
+ return maybeGithub(p, name, er, cb)
+ }
+ return cb(er)
+ }
if (s.isDirectory()) addLocalDirectory(p, name, cb)
else addLocalTarball(p, name, cb)
})
})
}
+function maybeGithub (p, name, er, cb) {
+ var u = "git://github.com/" + p
+ , up = url.parse(u)
+ log.info("maybeGithub", "Attempting to fetch %s from %s", p, u)
+ return addRemoteGit(u, up, name, function (er2, data) {
+ if (er2) return cb(er)
+ return cb(null, data)
+ })
+}
+
function addLocalTarball (p, name, cb) {
if (typeof cb !== "function") cb = name, name = ""
// if it's a tar, and not in place,
View
@@ -16,7 +16,8 @@ var npm = require("./npm.js")
})
, shorthandNames = Object.keys(shorthands)
, allConfs = configNames.concat(shorthandNames)
- , npm = require("./npm.js")
+ , once = require("once")
+
completion.completion = function (opts, cb) {
if (opts.w > 3) return cb()
@@ -150,6 +151,10 @@ function dumpScript (cb) {
, path = require("path")
, p = path.resolve(__dirname, "utils/completion.sh")
+ // The Darwin patch below results in callbacks first for the write and then
+ // for the error handler, so make sure we only call our callback once.
+ cb = once(cb)
+
fs.readFile(p, "utf8", function (er, d) {
if (er) return cb(er)
d = d.replace(/^\#\!.*?\n/, "")
@@ -166,7 +171,7 @@ function dumpScript (cb) {
// Really, one should not be tossing away EPIPE errors, or any
// errors, so casually. But, without this, `. <(npm completion)`
// can never ever work on OS X.
- if (er.errno === require("constants").EPIPE) er = null
+ if (er.errno === "EPIPE") er = null
cb(er)
})
View
@@ -65,7 +65,13 @@ function publish_ (arg, data, isRetry, cachedir, cb) {
var registry = npm.registry
if (data.publishConfig) {
var pubConf = new Conf(npm.config)
- pubConf.unshift(data.publishConfig)
+
+ // don't modify the actual publishConfig object, in case we have
+ // to set a login token or some other data.
+ pubConf.unshift(Object.keys(data.publishConfig).reduce(function (s, k) {
+ s[k] = data.publishConfig[k]
+ return s
+ }, {}))
registry = new RegClient(pubConf)
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit a4ea3de

Please sign in to comment.