Comparing version 2.0.0 to 2.1.0
@@ -47,2 +47,3 @@ var esprima = require('esprima'); | ||
var modules = { strings : [], expressions : [] }; | ||
if (opts.nodes) modules.nodes = []; | ||
@@ -60,2 +61,3 @@ if (src.indexOf(word) == -1) return modules; | ||
} | ||
if (opts.nodes) modules.nodes.push(node); | ||
}); | ||
@@ -62,0 +64,0 @@ |
{ | ||
"name" : "detective", | ||
"description" : "Find all calls to require() no matter how crazily nested using a proper walk of the AST", | ||
"version" : "2.0.0", | ||
"version" : "2.1.0", | ||
"repository" : { | ||
@@ -6,0 +6,0 @@ "type" : "git", |
@@ -10,3 +10,18 @@ var test = require('tap').test; | ||
t.deepEqual(modules.expressions, [ "'c' + x", "'d' + y" ]); | ||
t.notOk(modules.nodes, 'has no nodes'); | ||
t.end(); | ||
}); | ||
test('both with nodes specified in opts', function (t) { | ||
var modules = detective.find(src, { nodes: true }); | ||
t.deepEqual(modules.strings, [ 'a', 'b' ]); | ||
t.deepEqual(modules.expressions, [ "'c' + x", "'d' + y" ]); | ||
t.deepEqual( | ||
modules.nodes.map(function (n) { | ||
var arg = n.arguments[0]; | ||
return arg.value || arg.left.value; | ||
}), | ||
[ 'a', 'b', 'c', 'd' ], | ||
'has a node for each require'); | ||
t.end(); | ||
}); |
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
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
8481
179
74