work.suroh.tk/node_modules/detective-cjs
suroh 410082595a init 11ty commit 2019-12-02 13:22:45 +01:00
..
Readme.md init 11ty commit 2019-12-02 13:22:45 +01:00
index.js init 11ty commit 2019-12-02 13:22:45 +01:00
package.json init 11ty commit 2019-12-02 13:22:45 +01:00

Readme.md

detective-cjs npm npm

Get the dependencies of an CommonJS module

npm install detective-cjs

But dude, substack already built this: node-detective. Yes, but I needed the capability to reuse an AST and this was unlikely to be merged timely. I can also support jsx and other syntactic constructs faster.

Usage

var detective = require('detective-cjs');

var mySourceCode = fs.readFileSync('myfile.js', 'utf8');

// Pass in a file's content or an AST
var dependencies = detective(mySourceCode);

License

MIT