find-requires
Advanced tools
Comparing version 0.1.6 to 0.2.0
'use strict'; | ||
var last = require('es5-ext/lib/Array/prototype/last') | ||
var last = require('es5-ext/array/#/last') | ||
, runInNewContext = require('vm').runInNewContext | ||
@@ -14,5 +14,3 @@ , esprima = require('esprima') | ||
var dep, lines; | ||
if (!ast || (typeof ast !== 'object')) { | ||
return; | ||
} | ||
if (!ast || (typeof ast !== 'object')) return; | ||
if (isArray(ast)) { | ||
@@ -23,5 +21,3 @@ ast.forEach(walker, this); | ||
keys(ast).forEach(function (key) { | ||
if (key !== 'range') { | ||
walker.call(this, ast[key]); | ||
} | ||
if (key !== 'range') walker.call(this, ast[key]); | ||
}, this); | ||
@@ -45,3 +41,3 @@ if ((ast.type === 'CallExpression') && (ast.callee.type === 'Identifier') && | ||
dep.value = String(runInNewContext(dep.raw)); | ||
} catch (e2) {} | ||
} catch (ignore) {} | ||
} | ||
@@ -57,5 +53,3 @@ } else if (!ast.arguments.length) { | ||
module.exports = function (code) { | ||
if (code == null) { | ||
throw new TypeError('Expected code string'); | ||
} | ||
if (code == null) throw new TypeError('Expected code string'); | ||
code = String(code); | ||
@@ -62,0 +56,0 @@ var ctx = { code: code, deps: [] }; |
'use strict'; | ||
var last = require('es5-ext/lib/Array/prototype/last') | ||
var last = require('es5-ext/array/#/last') | ||
@@ -75,7 +75,6 @@ , stringify = JSON.stringify, min = Math.min | ||
throw e; | ||
} else { | ||
// not RegExp | ||
current = slash + 1; | ||
return false; | ||
} | ||
// not RegExp | ||
current = slash + 1; | ||
return false; | ||
} | ||
@@ -109,3 +108,3 @@ return pass(slash, '/'); | ||
argsError = function () { | ||
var e = new Error("Cannot parse code" + " @" + (current) + ": " + | ||
var e = new Error("Cannot parse code @" + current + ": " + | ||
stringify(code.slice(current - 8, current + 10)) + "." + | ||
@@ -137,3 +136,3 @@ " Found unexpected code in `require` call. Try AST parser instead."); | ||
if (!ws) return; | ||
e = new Error("Cannot parse code" + " @" + (require) + ": " + | ||
e = new Error("Cannot parse code @" + require + ": " + | ||
stringify(code.slice(require - 8, require + 17)) + "." + | ||
@@ -140,0 +139,0 @@ " `require` preceded by unexpected code. Try AST parser instead."); |
{ | ||
"name": "find-requires", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"description": "Find all require() calls. Fast and solid implementation backed with direct scanner and esprima AST parser", | ||
"author": "Mariusz Nowak <medyk@medikoo.com>", | ||
"keywords": [ | ||
@@ -20,4 +21,2 @@ "analyze", | ||
], | ||
"author": "Mariusz Nowak <medikoo+find-requires@medikoo.com>", | ||
"main": "lib", | ||
"repository": { | ||
@@ -27,21 +26,13 @@ "type": "git", | ||
}, | ||
"bugs": { | ||
"email": "medikoo+find-requires@medikoo.com", | ||
"url": "https://github.com/medikoo/find-requires/issues" | ||
}, | ||
"dependencies": { | ||
"esprima": "1.x", | ||
"es5-ext": "~0.9.2" | ||
"esprima": "~1.1.1", | ||
"es5-ext": "~0.10.2" | ||
}, | ||
"devDependencies": { | ||
"tad": "~0.1.15" | ||
"tad": "0.2.x" | ||
}, | ||
"scripts": { | ||
"test": "node ./node_modules/tad/bin/tad lib" | ||
"test": "node ./node_modules/tad/bin/tad" | ||
}, | ||
"licence": "MIT", | ||
"optionalDependencies": {}, | ||
"engines": { | ||
"node": ">=0.4" | ||
} | ||
"licence": "MIT" | ||
} |
@@ -70,7 +70,6 @@ require('on\u0065') | ||
require("object3" + { foo: bar() }); | ||
/"/, require("object3" + { foo: bar() }); | ||
require.foo; | ||
function test() { | ||
@@ -119,3 +118,5 @@ a();return require(('four') + 'teen'); | ||
} | ||
isNaN();require('mid-thirty') | ||
require('inner' + require(require('marko')) + 'elo') | ||
require('thirty\ | ||
@@ -122,0 +123,0 @@ break-line \ |
@@ -36,2 +36,4 @@ require('on\u0065') | ||
var maro = [,,,] | ||
// require('comment'); | ||
@@ -87,2 +89,2 @@ var raz = 4; // require('comment2') | ||
module.exports = require('thirty\two') | ||
module.exports = /"/, require('thirty\two') |
@@ -14,3 +14,3 @@ 'use strict'; | ||
'\'twenty/seven\'', '"twenty/eight', '"twenty/nine"', '"thirty"', | ||
'thirty\tbreak-line \tone', 'thirty\two']; | ||
'mid-thirty', 'marko', 'thirty\tbreak-line \tone', 'thirty\two']; | ||
@@ -17,0 +17,0 @@ readFile(pg + '/edge.js', 'utf-8', function (err, str) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
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
581
19839
21
2
19
+ Addedd@1.0.2(transitive)
+ Addedes5-ext@0.10.64(transitive)
+ Addedes6-iterator@2.0.3(transitive)
+ Addedes6-symbol@3.1.4(transitive)
+ Addedesniff@2.0.1(transitive)
+ Addedesprima@1.1.1(transitive)
+ Addedevent-emitter@0.3.5(transitive)
+ Addedext@1.7.0(transitive)
+ Addednext-tick@1.1.0(transitive)
+ Addedtype@2.7.3(transitive)
- Removedes5-ext@0.9.2(transitive)
- Removedesprima@1.2.5(transitive)
Updatedes5-ext@~0.10.2
Updatedesprima@~1.1.1