Comparing version 0.3.2 to 0.3.3
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 = resolve(name); | ||
path = require.resolve(name); | ||
} catch (err) { | ||
@@ -55,3 +25,3 @@ throw new Error('Could not drop non existing module "' + name + '"'); | ||
try { | ||
path = resolve(name); | ||
path = require.resolve(name); | ||
} catch (err) { | ||
@@ -107,3 +77,3 @@ throw new Error('Could not modify non existing module "' + name + '"'); | ||
try { | ||
path = resolve(name); | ||
path = require.resolve(name); | ||
} catch (err) { | ||
@@ -110,0 +80,0 @@ throw new Error('Could not restore non existing module "' + name + '"'); |
{ | ||
"name": "cuculus", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"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
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
7958
149
11