@ -95,12 +95,10 @@ function cache (args, cb) {
// if the pkg and ver are in the cache, then
// if the pkg and ver are in the cache, then
// just do a readJson and return.
// just do a readJson and return.
// if they're not, then fetch them from the registry.
// if they're not, then fetch them from the registry.
var cacheSeen = { }
function read ( name , ver , forceBypass , cb ) {
function read ( name , ver , forceBypass , cb ) {
if ( typeof cb !== "function" ) cb = forceBypass , forceBypass = true
if ( typeof cb !== "function" ) cb = forceBypass , forceBypass = true
var jsonFile = path . join ( npm . cache , name , ver , "package" , "package.json" )
var jsonFile = path . join ( npm . cache , name , ver , "package" , "package.json" )
function c ( er , data ) {
function c ( er , data ) {
if ( ! er ) cacheSeen [ data . _ id ] = data
if ( data ) deprCheck ( data )
if ( data ) deprCheck ( data )
return cb ( er , data )
return cb ( er , data )
}
}
@ -110,10 +108,6 @@ function read (name, ver, forceBypass, cb) {
return addNamed ( name , ver , c )
return addNamed ( name , ver , c )
}
}
if ( name + "@" + ver in cacheSeen ) {
return cb ( null , cacheSeen [ name + "@" + ver ] )
}
readJson ( jsonFile , function ( er , data ) {
readJson ( jsonFile , function ( er , data ) {
if ( er ) return addNamed ( name , ver , c )
if ( er ) return addNamed ( name , ver , c )
deprCheck ( data )
deprCheck ( data )
@ -126,9 +120,13 @@ function ls (args, cb) {
output = output || require ( "./utils/output.js" )
output = output || require ( "./utils/output.js" )
args = args . join ( "/" ) . split ( "@" ) . join ( "/" )
args = args . join ( "/" ) . split ( "@" ) . join ( "/" )
if ( args . substr ( - 1 ) === "/" ) args = args . substr ( 0 , args . length - 1 )
if ( args . substr ( - 1 ) === "/" ) args = args . substr ( 0 , args . length - 1 )
var prefix = npm . config . get ( "cache" )
if ( 0 === prefix . indexOf ( process . env . HOME ) ) {
prefix = "~" + prefix . substr ( process . env . HOME . length )
}
ls_ ( args , npm . config . get ( "depth" ) , function ( er , files ) {
ls_ ( args , npm . config . get ( "depth" ) , function ( er , files ) {
output . write ( files . map ( function ( f ) {
output . write ( files . map ( function ( f ) {
return path . join ( "~/.npm" , f )
return path . join ( prefix , f )
} ) . join ( "\n" ) . trim ( ) , function ( er ) {
} ) . join ( "\n" ) . trim ( ) , function ( er ) {
return cb ( er , files )
return cb ( er , files )
} )
} )
@ -212,7 +210,7 @@ function add (args, cb) {
// see if the spec is a url
// see if the spec is a url
// otherwise, treat as name@version
// otherwise, treat as name@version
var p = url . parse ( spec . replace ( /^git\+/ , "git" ) ) || { }
var p = url . parse ( spec ) || { }
log . verbose ( p , "parsed url" )
log . verbose ( p , "parsed url" )
// it could be that we got name@http://blah
// it could be that we got name@http://blah
@ -230,11 +228,11 @@ function add (args, cb) {
case "https:" :
case "https:" :
return addRemoteTarball ( spec , null , name , cb )
return addRemoteTarball ( spec , null , name , cb )
case "git:" :
case "git:" :
case "githttp:" :
case "git+ http:" :
case "githttps:" :
case "git+ https:" :
case "gitrsync:" :
case "git+ rsync:" :
case "gitftp:" :
case "git+ ftp:" :
case "gitssh:" :
case "git+ ssh:" :
//p.protocol = p.protocol.replace(/^git([^:])/, "$1")
//p.protocol = p.protocol.replace(/^git([^:])/, "$1")
return addRemoteGit ( spec , p , name , cb )
return addRemoteGit ( spec , p , name , cb )
default :
default :