diff options
Diffstat (limited to 'deps/npm/lib/cache.js')
-rw-r--r-- | deps/npm/lib/cache.js | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/deps/npm/lib/cache.js b/deps/npm/lib/cache.js index c06c4728d..c2f870bf1 100644 --- a/deps/npm/lib/cache.js +++ b/deps/npm/lib/cache.js @@ -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, |