Comparing version 2.2.0 to 2.3.0
11
index.js
@@ -24,4 +24,4 @@ var esprima = require('esprima'); | ||
var walk = function (src, cb) { | ||
var ast = esprima.parse(src); | ||
var walk = function (src, opts, cb) { | ||
var ast = esprima.parse(src, opts); | ||
traverse(ast, cb); | ||
@@ -36,5 +36,8 @@ }; | ||
if (!opts) opts = {}; | ||
opts.parse = opts.parse || {}; | ||
opts.parse.tolerant = true; | ||
var word = opts.word === undefined ? 'require' : opts.word; | ||
if (typeof src !== 'string') src = String(src); | ||
src = '(function(){' + src.replace(/^#![^\n]*\n/, '') + '\n})()'; | ||
src = src.replace(/^#![^\n]*\n/, ''); | ||
@@ -55,3 +58,3 @@ var isRequire = opts.isRequire || function (node) { | ||
walk(src, function (node) { | ||
walk(src, opts.parse, function (node) { | ||
if (!isRequire(node)) return; | ||
@@ -58,0 +61,0 @@ if (node.arguments.length |
{ | ||
"name" : "detective", | ||
"description" : "find all require() calls by walking the AST", | ||
"version" : "2.2.0", | ||
"version" : "2.3.0", | ||
"repository" : { | ||
@@ -6,0 +6,0 @@ "type" : "git", |
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
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
12669
26
287
79
13