Comparing version 0.3.1 to 0.3.2
var PREVIOUS = Symbol('PREVIOUS'); | ||
var ON_RESTORE = Symbol('ON_RESTORE'); | ||
var _path = require('path'); | ||
function resolve(name) { | ||
var attempts, path; | ||
// lazy style attempts | ||
attempts = [ | ||
function() { | ||
return name; | ||
}, | ||
function() { | ||
return _path.resolve(process.cwd(), name); | ||
} | ||
]; | ||
while (!path && attempts.length > 0) { | ||
try { | ||
path = require.resolve(attempts.shift().call()); | ||
} catch (err) { | ||
// | ||
} | ||
} | ||
if (!path) { | ||
throw new Error('Could not resolve path for module "' + name + '"'); | ||
} | ||
return path; | ||
} | ||
exports.drop = function(name) { | ||
try { | ||
path = require.resolve(name); | ||
path = resolve(name); | ||
} catch (err) { | ||
@@ -25,3 +55,3 @@ throw new Error('Could not drop non existing module "' + name + '"'); | ||
try { | ||
path = require.resolve(name); | ||
path = resolve(name); | ||
} catch (err) { | ||
@@ -77,3 +107,3 @@ throw new Error('Could not modify non existing module "' + name + '"'); | ||
try { | ||
path = require.resolve(name); | ||
path = resolve(name); | ||
} catch (err) { | ||
@@ -80,0 +110,0 @@ throw new Error('Could not restore non existing module "' + name + '"'); |
{ | ||
"name": "cuculus", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"engines" : { "node" : ">=0.12.0" }, | ||
@@ -5,0 +5,0 @@ "description": "Simplest require mocking", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8504
173
9