Created
April 7, 2014 19:10
-
-
Save pvenkatakrishnan/16bc07eb282bfebf1087 to your computer and use it in GitHub Desktop.
Config in kraken / confit - Proposal 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateConfig(baseDir, protocols, overrides) { | |
var deferred, factory; | |
deferred = q.defer(); | |
factory = confit({ basedir: baseDir, protocols: protocols }); | |
overrides.forEach(function(entry) { | |
factory.override(entry); | |
}); | |
factory.create(function (err, config) { | |
var ovride; | |
if (err) { | |
deferred.reject(err); | |
return; | |
} | |
deferred.resolve(config); | |
}); | |
return deferred.promise; | |
} | |
exports.create = function create(options) { | |
var protocols; | |
protocols = createHandlers(options); | |
//generate the override config file list by scanning the app's config directory | |
//then generate the config object by creating a factory and applying the overrides. | |
//CHALLENGES: | |
//1.Need to find out the env before creating the factory, currently with existing interface | |
//that is not possible | |
//ADVANTAGE: | |
// | |
return generateConfig(fileName, protocols, [overideFileA, overrideFileB])); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment