Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

npm-registry-client

Package Overview
Dependencies
Maintainers
1
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-registry-client - npm Package Compare versions

Comparing version 0.4.12 to 1.0.0

4

index.js

@@ -9,2 +9,3 @@ // utilities for working with the js-registry site.

, npmlog
, cacheFile = require('npm-cache-filename')

@@ -49,3 +50,6 @@ try {

this.registry = registry
if (!conf.get('cache')) throw new Error("Cache dir is required")
this.cacheFile = cacheFile(this.conf.get('cache'))
this.log = conf.log || conf.get('log') || npmlog

@@ -52,0 +56,0 @@ }

25

lib/get.js

@@ -24,2 +24,4 @@

var cache = this.cacheFile(this.registry + uri) + "/.cache.json"
// /-/all is special.

@@ -29,10 +31,5 @@ // It uses timestamp-based caching and partial updates,

if (uri === "/-/all") {
return requestAll.call(this, cb)
return requestAll.call(this, cache, cb)
}
var cacheUri = uri
// on windows ":" is not an allowed character in a foldername
cacheUri = cacheUri.replace(/:/g, '_').replace(/\?write=true$/, '')
var cache = path.join(this.conf.get('cache'), cacheUri, ".cache.json")
// If the GET is part of a write operation (PUT or DELETE), then

@@ -54,9 +51,6 @@ // skip past the cache entirely, but still save the results.

function requestAll (cb) {
var cache = path.join(this.conf.get('cache'), "/-/all", ".cache.json")
mkdir(path.join(this.conf.get('cache'), "-", "all"), function (er) {
if (er) return cb(er)
function requestAll (cache, cb) {
mkdir(path.dirname(cache), function (er) {
fs.readFile(cache, function (er, data) {
if (er) return requestAll_.call(this, 0, {}, cb)
if (er) return requestAll_.call(this, 0, {}, cache, cb)
try {

@@ -67,7 +61,7 @@ data = JSON.parse(data)

if (er) return cb(new Error("Broken cache."))
return requestAll_.call(this, 0, {}, cb)
return requestAll_.call(this, 0, {}, cache, cb)
}.bind(this))
}
var t = +data._updated || 0
requestAll_.call(this, t, data, cb)
requestAll_.call(this, t, data, cache, cb)
}.bind(this))

@@ -77,3 +71,3 @@ }.bind(this))

function requestAll_ (c, data, cb) {
function requestAll_ (c, data, cache, cb) {
// use the cache and update in the background if it's not too old

@@ -92,3 +86,2 @@ if (Date.now() - c < 60000) {

var cache = path.join(this.conf.get('cache'), "-/all", ".cache.json")
this.request('GET', uri, function (er, updates, _, res) {

@@ -95,0 +88,0 @@ if (er) return cb(er, data)

@@ -284,22 +284,3 @@ module.exports = regRequest

// only result will be a stale cache for some helper commands.
var path = require("path")
, p = url.parse(where).pathname.split("/")
, _ = "/"
, caches = p.map(function (part) {
part = part.replace(/:/g, "_")
return _ = path.join(_, part)
}).map(function (cache) {
return path.join(this.conf.get('cache'), cache, ".cache.json")
}, this)
// if the method is DELETE, then also remove the thing itself.
// Note that the search index is probably invalid. Whatever.
// That's what you get for deleting stuff. Don't do that.
if (method === "DELETE") {
p = p.slice(0, p.indexOf("-rev"))
p = p.join("/").replace(/:/g, "_")
caches.push(path.join(this.conf.get('cache'), p))
}
asyncMap(caches, rm, function () {})
rm(this.cacheFile(where), function() {})
}

@@ -306,0 +287,0 @@ return cb(er, parsed, data, response)

@@ -5,3 +5,3 @@ {

"description": "Client for the npm registry",
"version": "0.4.12",
"version": "1.0.0",
"repository": {

@@ -15,10 +15,11 @@ "url": "git://github.com/isaacs/npm-registry-client"

"dependencies": {
"request": "2 >=2.25.0",
"chownr": "0",
"graceful-fs": "~2.0.0",
"semver": "2 >=2.2.1",
"slide": "~1.1.3",
"chownr": "0",
"mkdirp": "~0.3.3",
"npm-cache-filename": "^1.0.0",
"request": "2 >=2.25.0",
"retry": "0.6.0",
"rimraf": "~2",
"retry": "0.6.0"
"semver": "2 >=2.2.1",
"slide": "~1.1.3"
},

@@ -25,0 +26,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc