cmd-deps
v3.2.2
Published
Transform cmd and get cmd dependences.
Downloads
25
Maintainers
Readme
cmd-deps
Transform cmd and get cmd dependences
Installation
npm install cmd-deps
Api
- parseDependencies(code:String|Buffer, options:Object):Object
- parseDependencies(code:String|Buffer, replace:Function, options:Object):Object
- options { acorn:Object, word:String, flags:Array }
- acorn: acorn options
- word: dependencies function name
- flags: dependencies function method name
- options { acorn:Object, word:String, flags:Array }
Example
source:
require('a');
//require('b');
/require('c')/;
('require("d")');
if (true) /require('e')/;
do /require('f')/.test(s);
while (false);
require.async('g');
require.async(['h']);
js:
const parseDependencies = require('cmd-deps');
const dependencies = parseDependencies(source, { flags: ['async'] }).dependencies;
// print dependencies
console.log(dependencies);
parser output:
[
{
flag: null,
path: 'a'
},
{
flag: 'async',
path: 'g'
},
{
flag: 'async',
path: 'h'
}
];