This commit is contained in:
Julian Lam
2014-02-14 11:49:16 -05:00
parent 734d8f96e8
commit d933e81b37
2 changed files with 15 additions and 3 deletions

11
app.js
View File

@@ -62,10 +62,17 @@ winston.info('This program comes with ABSOLUTELY NO WARRANTY.');
winston.info('This is free software, and you are welcome to redistribute it under certain conditions.');
winston.info('');
// Alternate configuration file support
var configFile = __dirname + '/config.json',
configExists;
if (nconf.get('config')) {
configFile = path.join(__dirname, nconf.get('config'));
}
configExists = fs.existsSync(configFile);
if (!nconf.get('help') && !nconf.get('setup') && !nconf.get('install') && !nconf.get('upgrade') && fs.existsSync(__dirname + '/config.json')) {
if (!nconf.get('help') && !nconf.get('setup') && !nconf.get('install') && !nconf.get('upgrade') && configExists) {
start();
} else if (nconf.get('setup') || nconf.get('install') || !fs.existsSync(__dirname + '/config.json')) {
} else if (nconf.get('setup') || nconf.get('install') || !configExists) {
setup();
} else if (nconf.get('upgrade')) {
upgrade();

View File

@@ -447,10 +447,15 @@ var async = require('async'),
}
},
save: function (server_conf, client_conf, callback) {
var serverConfigPath = path.join(__dirname, '../config.json');
if (nconf.get('config')) {
serverConfigPath = path.join(__dirname, '../', nconf.get('config'));
}
// Server Config
async.parallel([
function (next) {
fs.writeFile(path.join(__dirname, '../', 'config.json'), JSON.stringify(server_conf, null, 4), function (err) {
fs.writeFile(serverConfigPath, JSON.stringify(server_conf, null, 4), function (err) {
next(err);
});
},