Skip to content

Instantly share code, notes, and snippets.

@ded
Created May 15, 2013 17:24
Show Gist options
  • Save ded/5585682 to your computer and use it in GitHub Desktop.
Save ded/5585682 to your computer and use it in GitHub Desktop.
get dependency tree
function init(config) {
var util = require('app/util')
, render = require('client/lib/render')
, router = require('client/lib/router')
, controllers = config.controllers
controllers.forEach(function (c) {
require(c)
})
}
head
- var files = util.getDependencyTreeFiles('client/app')
each file, i in files
script(src=file)
@dfkaye
Copy link

dfkaye commented May 15, 2013

IOW, getDependencyTreeFiles would inspect the files under the specified directory for internal require calls - the jade then writes all the script tags directly, one per dep file.

Good candidate for this is @substack's module-deps ( see https://github.com/substack/module-deps ) which returns an array of JSON entries, each with { id, source} and write the the entry.id value to the script.src.

Copy link

ghost commented May 16, 2013

Or you can do browserify main.js --list to print a list of newline-separated filenames.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment