Liu Song’s Projects


~/Projects/deps-parser

git clone https://code.lsong.org/deps-parser

deps-parser

A simple way to get module dependencies

Install

~$ npm install deps-parser

Example

Suppose you have 2 files, one is a.js with content:

var b = require('./b')

another is b.js whose content is:

var c = require('./c');

Below is how we get the dependencies list of a.js:

var Deps = require('deps-parser');
var analyzer = new Deps();
var deps = analyzer.getDeps(__dirname + "/a.js");
console.log(deps); 
// output
[
  '{__dirname}/c.js'
  '{__dirname}/b.js'
]

License

This project is under MIT licence.