Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2014-05-02 04:55:27 +0400
committerForrest L Norvell <forrest@npmjs.com>2014-05-08 05:00:51 +0400
commitff35ed6b67489067a31f112d026dddfcf51b8929 (patch)
treee8df793966c8f22b787367ba445e0d763d5ed8af /lib
parent83d68b675f3ba7c095030b84b60e9a4566874d19 (diff)
reorganize for readability
Diffstat (limited to 'lib')
-rw-r--r--lib/cache.js86
-rw-r--r--lib/cache/add-remote-tarball.js4
2 files changed, 45 insertions, 45 deletions
diff --git a/lib/cache.js b/lib/cache.js
index 108ffe4c7..1ff8718ba 100644
--- a/lib/cache.js
+++ b/lib/cache.js
@@ -262,6 +262,48 @@ function add (args, cb) {
add_(name, spec, p, cb)
}
+function unpack (pkg, ver, unpackTarget, dMode, fMode, uid, gid, cb) {
+ if (typeof cb !== "function") cb = gid, gid = null
+ if (typeof cb !== "function") cb = uid, uid = null
+ if (typeof cb !== "function") cb = fMode, fMode = null
+ if (typeof cb !== "function") cb = dMode, dMode = null
+
+ read(pkg, ver, false, function (er) {
+ if (er) {
+ log.error("unpack", "Could not read data for %s", pkg + "@" + ver)
+ return cb(er)
+ }
+ npm.commands.unbuild([unpackTarget], true, function (er) {
+ if (er) return cb(er)
+ tar.unpack( path.join(npm.cache, pkg, ver, "package.tgz")
+ , unpackTarget
+ , dMode, fMode
+ , uid, gid
+ , cb )
+ })
+ })
+}
+
+function add_ (name, spec, p, cb) {
+ switch (p.protocol) {
+ case "http:":
+ case "https:":
+ return addRemoteTarball(spec, null, name, "", cb)
+
+ default:
+ if (isGitUrl(p))
+ return addRemoteGit(spec, p, false, cb)
+
+ // if we have a name and a spec, then try name@spec
+ // if not, then try just spec (which may try name@"" if not found)
+ if (name) {
+ addNamed(name, spec, null, cb)
+ } else {
+ addLocal(spec, "", cb)
+ }
+ }
+}
+
function afterAdd (arg, cb) { return function (er, data) {
if (er || !data || !data.name || !data.version) {
return cb(er, data)
@@ -277,8 +319,6 @@ function afterAdd (arg, cb) { return function (er, data) {
})
}}
-
-
function maybeFile (spec, p, cb) {
fs.stat(spec, function (er) {
if (!er) {
@@ -304,48 +344,6 @@ function maybeAt (spec, cb) {
return add([name, spec], cb)
}
-function add_ (name, spec, p, cb) {
- switch (p.protocol) {
- case "http:":
- case "https:":
- return addRemoteTarball(spec, null, name, "", cb)
-
- default:
- if (isGitUrl(p))
- return addRemoteGit(spec, p, false, cb)
-
- // if we have a name and a spec, then try name@spec
- // if not, then try just spec (which may try name@"" if not found)
- if (name) {
- addNamed(name, spec, null, cb)
- } else {
- addLocal(spec, "", cb)
- }
- }
-}
-
-function unpack (pkg, ver, unpackTarget, dMode, fMode, uid, gid, cb) {
- if (typeof cb !== "function") cb = gid, gid = null
- if (typeof cb !== "function") cb = uid, uid = null
- if (typeof cb !== "function") cb = fMode, fMode = null
- if (typeof cb !== "function") cb = dMode, dMode = null
-
- read(pkg, ver, false, function (er) {
- if (er) {
- log.error("unpack", "Could not read data for %s", pkg + "@" + ver)
- return cb(er)
- }
- npm.commands.unbuild([unpackTarget], true, function (er) {
- if (er) return cb(er)
- tar.unpack( path.join(npm.cache, pkg, ver, "package.tgz")
- , unpackTarget
- , dMode, fMode
- , uid, gid
- , cb )
- })
- })
-}
-
function needName(er, data) {
return er ? er
: (data && !data.name) ? new Error("No name provided")
diff --git a/lib/cache/add-remote-tarball.js b/lib/cache/add-remote-tarball.js
index e5c344ef4..7d5a9ae6f 100644
--- a/lib/cache/add-remote-tarball.js
+++ b/lib/cache/add-remote-tarball.js
@@ -14,7 +14,9 @@ var mkdir = require("mkdirp")
, unlock = locker.unlock
, addLocalTarball = require("./add-local-tarball.js")
-module.exports = function addRemoteTarball (u, shasum, name, version, cb_) {
+module.exports = addRemoteTarball
+
+function addRemoteTarball (u, shasum, name, version, cb_) {
assert(typeof u === "string", "must have module URL")
assert(typeof cb_ === "function", "must have callback")