Skip to content

Commit

Permalink
don't override config values that were set before the plugin start
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer committed May 3, 2011
1 parent 60a71f1 commit d798646
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions server/plugin.js
Expand Up @@ -34,6 +34,7 @@ require.extensions['.bones'] = function(module, filename) {
module.exports = Plugin;
function Plugin() {
this.directories = [];
this.config = {};
this.controllers = {};
this.models = {};
this.routers = {};
Expand Down Expand Up @@ -85,18 +86,18 @@ Plugin.prototype.start = function() {
this.help();
} else {
var command = this.commands[command];
this.config = this.loadConfig(command);
this.loadConfig(command);
return new command(this);
}
};

Plugin.prototype.loadConfig = function(command) {
var config = {};
var config = this.config;
command.options = command.options || {};

if (this.argv.config) {
try {
config = JSON.parse(fs.readFileSync(this.argv.config, 'utf8'));
_.extend(config, JSON.parse(fs.readFileSync(this.argv.config, 'utf8')));
} catch(e) {
console.error(utils.colorize('Invalid JSON config file: ' +
this.argv.config, 'red'));
Expand Down Expand Up @@ -152,8 +153,6 @@ Plugin.prototype.loadConfig = function(command) {
console.warn(utils.colorize('Using configuration:', 'green'));
console.warn(JSON.stringify(config, false, 4));
}

return config;
};

Plugin.prototype.help = function() {
Expand Down

0 comments on commit d798646

Please sign in to comment.