Take a file and recursively discover all the files loaded in using <code>require()</code>.
Take a file and recursively discover all the files loaded in using
$ npm install reqursive
reqursive on a file, and soon after you'll get an array containing
a list of all the scripts that file requires before running.
var worker =async =
You might have noticed that reqursive steers clear of the insides of
by default. By passing the
traverseModules option as true you'll get back
not only the modules, but their contents as well:
var async =reqursive =
You can pass in an array of files to evaluate them together - they don't have to be connected, but they can be. If the files are from separate directories, the returned paths will be relative to the first file by default.
If you're looking to just get the files required by a single script, you can
var reqursive =filename = requirereqursive
reqursive.children methods return an array of file
objects, each with the following properties:
id: Either the name of the module or the name of the file, e.g.
filename: The path to the file. When using
reqursive, this is relative to
the original file. When using
reqursive.children, the path is absolute.
module: true if the file is a module: taken from
node_modules, or a part
of Node's core.
native: true if the file is a native module, e.g.
net, but not
parents: An array of scripts that require this file.
mgroup: This is equal to the id of the module this file is a part of.
Top-level scripts, i.e. not part of a module, will have an "mgroup" equal to
error: If a syntax error was picked up when parsing this file, it'll go
here. Handle this however you please.
The following only apply to
traverseModules: Don't stop when hitting a module - keep going through the
module's files too.
absolute: Return absolute paths instead of relative.