package
find all require() calls by walking the AST
npm install detectiveGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 7 packages.
742.9 kB
Includes dependencies.
find all calls to require() by walking the AST
strings_src.js:
var a = require('a');
var b = require('b');
var c = require('c');strings.js:
var detective = require('detective');
var fs = require('fs');
var src = fs.readFileSync(__dirname + '/strings_src.js');
var requires = detective(src);
console.dir(requires);output:
$ node examples/strings.js
[ 'a', 'b', 'c' ]var detective = require('detective');Give some source body src, return an array of all the require() calls with
string arguments.
The options parameter opts is passed along to detective.find().
Give some source body src, return found with:
found.strings - an array of each string found in a require()found.expressions - an array of each stringified expression found in a
require() callfound.nodes (when opts.nodes === true) - an array of AST nodes for each
argument found in a require() callOptionally:
opts.word - specify a different function name instead of "require"opts.nodes - when true, populate found.nodesopts.isRequire(node) - a function returning whether an AST CallExpression
node is a require callopts.parse - supply options directly to
acorn with some support for esprima-style
options range and locopts.ecmaVersion - default: 9With npm do:
npm install detectiveMIT
gkatsev
me@gkatsev.com
maxogden
max@maxogden.com
thlorenz
thlorenz10@gmail.com
terinjokes
terinjokes@gmail.com
jmm
npm-public@jessemccarthy.net
mellowmelon
palmermebane@gmail.com
ashaffer88
darawk@gmail.com
balupton
b@lupton.cc
cwmma
calvin.metcalf@gmail.com
jprichardson
jprichardson@gmail.com
indutny
blackhole@livebox.sh
jryans
jryans@gmail.com
sethvincent
sethvincent@gmail.com
yoshuawuyts
javascript@yosh.is
ungoldman
ungoldman@gmail.com
ahdinosaur
michael.williams@enspiral.com
elnounch
contact@elnounch.net
parshap
parshap+npm@gmail.com
yerkopalma
yerko.palma@usach.cl
forbeslindesay
forbes@lindesay.co.uk
leichtgewicht
martin.heidegger@gmail.com
garann
garann@gmail.com
bret
bcomnes@gmail.com
anandthakker
vestibule@anandthakker.net
mattdesl
dave.des@gmail.com
hughsk
hughskennedy@gmail.com
fpereira1
pereira.filype@gmail.com
goto-bus-stop
renee@kooi.me
bpostlethwaite
post.ben.here@gmail.com
emilbayes
github@tixz.dk
stevemao
maochenyan@gmail.com
pkrumins
peteris.krumins@gmail.com
tehshrike
me@JoshDuff.com
defunctzombie
shtylman@gmail.com
lukechilds
lukechilds123@gmail.com
raynos
raynos2@gmail.com