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
Example
source:
require('a');
/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;
console.log(dependencies);
parser output:
[
{
flag: null,
path: 'a'
},
{
flag: 'async',
path: 'g'
},
{
flag: 'async',
path: 'h'
}
];
License
MIT