diff options
author | Rebecca Turner <turner@mikomi.org> | 2014-09-04 20:45:55 +0400 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2014-09-05 09:35:00 +0400 |
commit | fa794138bec8edb7b88639db25ee9c010d2f4c2b (patch) | |
tree | c6fbeff9aab64e1771653321a1abffb24434b2b1 /lib | |
parent | d845e9d84066e77359964c2c73e9dcf56ac8ccab (diff) |
Fallback to module installs if package.json is missing in a local
folder
Fixes #6117
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cache.js | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/cache.js b/lib/cache.js index ae31e4d18..d2ac20774 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -270,11 +270,24 @@ function add (args, cb) { log.verbose("parsed spec", p) // short-circuit local installs - fs.stat(path.resolve(p.spec), function (er) { - if (!er) { - log.verbose("cache add", "local package", path.resolve(spec)) - return addLocal(p.spec, null, cb) - } + fs.stat(path.resolve(p.spec), function (er, s) { + if (er) return addNonLocal(spec, cb); + if (! s.isDirectory()) return addAndLogLocal(spec,cb); + fs.stat(path.join(spec, 'package.json'), function (er) { + if (er) return addNonLocal(spec, cb); + addAndLogLocal(spec,cb); + }) + }) +} + +function addAndLogLocal(spec, cb) { + log.verbose("cache add", "local package", path.resolve(spec)) + return addLocal(spec,null,cb) +} + +function addNonLocal(spec,cb) { + var p = npa(spec) + log.verbose("parsed spec", p) switch (p.type) { case "remote": @@ -291,7 +304,6 @@ function add (args, cb) { cb(new Error("couldn't figure out how to install " + spec)) } - }) } function unpack (pkg, ver, unpackTarget, dMode, fMode, uid, gid, cb) { |