Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Add name/version just like a normal remote tarball
Browse files Browse the repository at this point in the history
This strips out build directories and the like, which can in some cases
end up in registry tarballs.

Also, add a todo about the shasum thing.  Gotta get to that soonish.
  • Loading branch information
isaacs committed Nov 12, 2010
1 parent a5a2b6c commit 89ff888
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function add (args, cb) {
else addLocal(pkg, cb)
}
function addRemoteTarball (url, cb) {
// todo: take a shasum, and validate it.
var tmp = path.join(npm.tmp, Date.now()+"-"+Math.random()+".tgz")
fetch(url, tmp, function (er) {
if (er) return log.er(cb, "failed to fetch "+url)(er)
Expand All @@ -139,17 +140,10 @@ function addNameVersion (name, ver, cb) {
registry.get(name, ver, function (er, data, json) {
if (er) return cb(er)
deprCheck(data)
var folder = path.join(npm.cache, data.name, data.version)
, tgz = path.join(folder, "package.tgz")
mkdir(folder, function (er) {
if (er) return cb(er)
if (!data.dist || !data.dist.tarball) return cb(new Error(
"No dist.tarball in package data"))
fetch(data.dist.tarball.replace(/^https/,'http'), tgz, function (er) {
if (er) return cb(er)
addLocalTarball(tgz, cb)
})
})
if (!data.dist || !data.dist.tarball) return cb(new Error(
"No dist.tarball in package data"))
// todo: put the shasum in the data, and pass to addRemoteTarball
return addRemoteTarball(data.dist.tarball.replace(/^https/,'http'), cb)
})
}

Expand Down

0 comments on commit 89ff888

Please sign in to comment.