New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

require-inject

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

require-inject - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

CHANGELOG.md

21

index.js

@@ -22,19 +22,24 @@ "use strict";

function resolve(callerFilename, name) {
if (/^[.][.]?\//.test(name)) {
name = path.resolve(path.dirname(callerFilename), name)
}
return require.resolve(name)
}
var installGlobally = module.exports.installGlobally = function (toLoad, mocks) {
var callerFilename = caller() == module.filename ? caller(2) : caller();
// Inject all of our mocks
Object.keys(mocks).forEach(function(name){
var path = require.resolve(name)
var namePath = resolve(callerFilename, name)
if (mocks[name] == null) {
delete require.cache[path]
delete require.cache[namePath]
}
else {
require.cache[path] = {exports: mocks[name]}
require.cache[namePath] = {exports: mocks[name]}
}
})
var callerFilename = caller() == module.filename ? caller(2) : caller();
if (/^[.][.]?\//.test(toLoad)) {
toLoad = path.resolve(path.dirname(callerFilename), toLoad)
}
var toLoadPath = require.resolve(toLoad)
var toLoadPath = resolve(callerFilename, toLoad)

@@ -41,0 +46,0 @@ // remove any unmocked version previously loaded

{
"name": "require-inject",
"version": "1.3.0",
"version": "1.3.1",
"description": "A simple mock injector compatible needing no instrumentation in the libraries being tested",

@@ -23,3 +23,3 @@ "main": "index.js",

"devDependencies": {
"tap": "^0.4.13"
"tap": "^2.2.0"
},

@@ -26,0 +26,0 @@ "dependencies": {

@@ -27,3 +27,6 @@ require-inject

*module* is the name of the module you want to require.
*module* is the name of the module you want to require. This is what you'd
pass to `require` to load the module from your script. This means that for
relative paths, the path should be relative to your test script, not to the
thing you're injecting dependencies into.

@@ -30,0 +33,0 @@ *mocks* is an object with keys that are the names of the modules you want

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