Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
trace the dependency graph of a javascript file
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
example
test
.travis.yml
README.markdown
index.js
package.json

README.markdown

subdeps

Trace the dependency graph of a javascript file using detective and resolve.

build status

examples

tree.js

var subdeps = require('../');
var deps = subdeps.sync(__dirname + '/tree/start.js');
console.dir(deps);

output:

substack : node-subdeps $ node example/tree.js 
[ '/home/substack/projects/node-subdeps/example/tree/start.js',
  '/home/substack/projects/node-subdeps/node_modules/detective/index.js',
  '/home/substack/projects/node-subdeps/node_modules/detective/node_modules/burrito/index.js',
  '/home/substack/projects/node-subdeps/node_modules/detective/node_modules/burrito/node_modules/uglify-js/uglify-js.js',
  '/home/substack/projects/node-subdeps/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/parse-js.js',
  '/home/substack/projects/node-subdeps/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/process.js',
  '/home/substack/projects/node-subdeps/node_modules/detective/node_modules/burrito/node_modules/uglify-js/lib/squeeze-more.js',
  '/home/substack/projects/node-subdeps/node_modules/detective/node_modules/burrito/node_modules/traverse/index.js',
  '/home/substack/projects/node-subdeps/example/tree/lib/util.js',
  '/home/substack/projects/node-subdeps/example/tree/x.js' ]
substack : node-subdeps $ 

memory.js

var subdeps = require('../');
var deps = subdeps.sync('/a.js', { sources : {
    '/a.js' : "var b = require('./b');",
    '/b.js' : "var c = require('f')",
    '/c.js' : "var d = require('./lib/d.js')",
    '/lib/d.js' : "var e = require('e');",
    '/node_modules/e/index.js' : '55',
    '/node_modules/f/beep.js' : '"boop"',
    '/node_modules/f/package.json' : JSON.stringify({ main : "beep.js" })
} });
console.dir(deps);

output:

[ '/a.js', '/b.js', '/node_modules/f/beep.js' ]

methods

var subdeps = require('subdeps');

subdeps.sync(filename, opts)

Return an array of dependencies starting from the file filename and expanding out recursively and synchronously.

Overload resolve's normal behavior with:

  • opts.isFile
  • opts.readFileSync

If you have an object mapping filenames to string contents, pass it in as opts.sources and the file will be used for dependency analysis entirely in-memory.

install

With npm do:

npm install subdeps

and for the CLI tool do:

npm install -g subdeps

licence

MIT/X11

Something went wrong with that request. Please try again.