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

npm-registry-mock

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-registry-mock - npm Package Compare versions

Comparing version 0.6.2 to 0.6.3

34

index.js

@@ -10,3 +10,3 @@ var path = require("path")

module.exports = start
function start (port, cb) {
function start (options, cb) {
var minMax = {

@@ -16,21 +16,27 @@ max: Infinity,

},
mocks = {}
mocks = {},
options
if (typeof port == "function") {
cb = port
port = 1331
if (typeof options == "number") {
options = {port: options}
}
if (typeof port == "object") {
mocks = port.mocks || mocks
if (port.minReq && port.maxReq) {
minMax.max = port.maxReq
minMax.min = port.minReq
if (typeof options == "function") {
cb = options
options = {}
options.port = 1331
}
if (typeof options == "object") {
mocks = options.mocks || mocks
if (options.minReq && options.maxReq) {
minMax.max = options.maxReq
minMax.min = options.minReq
}
port.port = port.port || 1331
port.throwOnUnmatched = port.throwOnUnmatched === false ? false : true
options.port = options.port || 1331
options.throwOnUnmatched = options.throwOnUnmatched === false ? false : true
}
hock.createHock(port, function (err, hockServer) {
hock.createHock(options, function (err, hockServer) {
if (typeof mocks == "function") {

@@ -72,3 +78,3 @@ mocks(hockServer)

res = JSON.stringify(res).replace(/http:\/\/registry\.npmjs\.org/ig,
'http://localhost:' + port)
'http://localhost:' + options.port)

@@ -75,0 +81,0 @@ return hockServer[method](route).many(minMax).reply(status, res)

{
"name": "npm-registry-mock",
"version": "0.6.2",
"version": "0.6.3",
"description": "mock the npm registry",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -104,2 +104,15 @@ var assert = require("assert")

})
it("works with a passed object", function (done) {
mr({port: port}, function (s) {
npm.load({cache: tempdir, registry: address}, function () {
npm.commands.install(tempdir, "underscore@1.3.1", function (err) {
require.cache[path] = null
var version = require(path).version
assert.equal(version, "1.3.1")
s.close()
done()
})
})
})
})
})

@@ -106,0 +119,0 @@

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