+8
-47
| var path = require('path'); // if module is locally defined we path.resolve it | ||
| var find = require('find'); // https://www.npmjs.com/package/find | ||
| require.getRootDir = function () { | ||
| var keys = Object.keys(require.cache); | ||
| var parent = keys[0]; // the module that required decache | ||
| /* istanbul ignore else */ | ||
| if(parent.indexOf('node_modules') > -1) { | ||
| var end = parent.indexOf('node_modules'); | ||
| parent = parent.substring(0, end); | ||
| } else { | ||
| parent = path.resolve(path.normalize(parent +'../../..')); // resolve up! | ||
| } | ||
| return parent; | ||
| } | ||
| require.find = function (moduleName) { | ||
| var parent = require.getRootDir(); | ||
| // a locally defined module | ||
| if(moduleName.indexOf('/') > -1) { | ||
| // console.log("BEFORE: "+moduleName); | ||
| var last = moduleName.lastIndexOf('/'); | ||
| // strip everything before the forward slash | ||
| moduleName = moduleName.substring(last, moduleName.length).replace('/', ''); | ||
| // console.log('AFTER: '+moduleName); | ||
| var mod; | ||
| var ext = path.extname(moduleName); | ||
| if(ext === '') { | ||
| mod = moduleName + '\.js'; // append .js to file type by default | ||
| } | ||
| else { | ||
| mod = moduleName.replace(ext, '\\' + ext); // escape extension for regex | ||
| } | ||
| var re = new RegExp(mod,"g"); // regex to use when finding the file | ||
| var files = find.fileSync(re, parent); | ||
| var file; | ||
| var keys = Object.keys(require.cache); | ||
| for (var i = 0; i < files.length; i++) { | ||
| var f = files[i]; | ||
| if(keys.indexOf(f) > -1) { // won't this *always* be true? | ||
| file = f; | ||
| break; | ||
| } | ||
| } | ||
| return file; | ||
| } else { | ||
| return moduleName; | ||
| if (moduleName[0] === '.') { | ||
| moduleName = path.resolve(path.dirname(module.parent.filename), moduleName); | ||
| } | ||
| } | ||
| try { | ||
| return require.resolve(moduleName); | ||
| } catch (e) { | ||
| return; | ||
| } | ||
| }; | ||
@@ -53,0 +14,0 @@ /** |
+7
-13
| { | ||
| "name": "decache", | ||
| "version": "3.1.0", | ||
| "version": "4.0.0", | ||
| "description": "decache (Delete Cache) lets you delete modules from node.js require() cache; useful when testing your modules/projects.", | ||
@@ -9,4 +9,3 @@ "main": "decache.js", | ||
| "test": "./node_modules/.bin/istanbul cover ./node_modules/tape/bin/tape ./test/*.js", | ||
| "coverage": "./node_modules/.bin/istanbul cover ./node_modules/tape/bin/tape ./test/*.js && ./node_modules/.bin/istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100", | ||
| "jshint": "./node_modules/jshint/bin/jshint -c .jshintrc --exclude-path .gitignore ." | ||
| "coverage": "./node_modules/.bin/istanbul cover ./node_modules/tape/bin/tape ./test/*.js && ./node_modules/.bin/istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100" | ||
| }, | ||
@@ -25,3 +24,3 @@ "repository": { | ||
| ], | ||
| "author": "@besarthoxhaj & @nelsonic (with help from StackOverflow)", | ||
| "author": "@besarthoxhaj, @jupiter & @nelsonic (with help from StackOverflow)", | ||
| "license": "MIT", | ||
@@ -36,15 +35,10 @@ "bugs": { | ||
| "devDependencies": { | ||
| "istanbul": "^0.4.2", | ||
| "jshint": "^2.9.1", | ||
| "pre-commit": "^1.1.2", | ||
| "istanbul": "^0.4.4", | ||
| "pre-commit": "^1.1.3", | ||
| "tap-spec": "^4.1.1", | ||
| "tape": "^4.4.0" | ||
| "tape": "^4.6.0" | ||
| }, | ||
| "pre-commit": [ | ||
| "jshint", | ||
| "coverage" | ||
| ], | ||
| "dependencies": { | ||
| "find": "^0.2.4" | ||
| } | ||
| ] | ||
| } |
-29
| { | ||
| "asi" : true, | ||
| "laxbreak" : true, | ||
| "bitwise" : true, | ||
| "boss" : false, | ||
| "curly" : true, | ||
| "eqeqeq" : true, | ||
| "eqnull" : false, | ||
| "evil" : false, | ||
| "expr" : false, | ||
| "forin" : false, | ||
| "immed" : true, | ||
| "indent" : 2, | ||
| "latedef" : true, | ||
| "loopfunc" : false, | ||
| "noarg" : true, | ||
| "node" : true, | ||
| "regexp" : true, | ||
| "regexdash" : false, | ||
| "strict" : false, | ||
| "scripturl" : true, | ||
| "shadow" : false, | ||
| "supernew" : false, | ||
| "sub" : true, | ||
| "undef" : true, | ||
| "white" : true, | ||
| "browser" : true, | ||
| "globals": { "$": true } | ||
| } |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
0
-100%4
-20%0
-100%8885
-19.67%8
-11.11%147
-19.67%- Removed
- Removed
- Removed