 		(req, res, next) ->
 			return next() unless req.url is '/js/config.js'
 			
+			promises = []
+			pkgman.invoke 'config', (path, fn) -> promises.push fn req
+			
 			config = {}
-			pkgman.invoke 'config', (path, fn) -> _.extend config, fn req
-			
-			prettyPrintConfig = ->
-				[first, rest...] = (JSON.stringify config, null, '  ').split '\n'
-				([first].concat rest.map (line) -> '  ' + line).join '\n'
+			Promise.all(promises).then((subconfigs) ->
+				_.extend config, subconfig for subconfig in subconfigs
+			).then(->
 				
-			res.setHeader 'Content-Type', 'text/javascript'
-			
-			res.send """
+					prettyPrintConfig = ->
+						[first, rest...] = (JSON.stringify config, null, '  ').split '\n'
+						([first].concat rest.map (line) -> '  ' + line).join '\n'
+						
+					res.setHeader 'Content-Type', 'text/javascript'
+					
+					res.send """
 angular.module('shrub.config', []).provider('config', function() {
 
   var __slice = [].slice;


});
"""
			
	]


_ = require 'underscore'
nconf = require 'nconf'
Promise = require 'bluebird'

Config = (require 'config').Config
pkgman = require 'pkgman'
