From 2d4ceb8f9ffe921ca5b3cff1a2cc2d70eb917164 Mon Sep 17 00:00:00 2001 From: akhoury Date: Sun, 8 Dec 2013 11:59:48 -0500 Subject: [PATCH] should close #634 --- src/install.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/install.js b/src/install.js index 601fdff077..ba59ac4826 100644 --- a/src/install.js +++ b/src/install.js @@ -104,12 +104,12 @@ var async = require('async'), } }, function (next) { - var success = function(err, config) { + var success = function (err, config) { if (!config) { return next(new Error('aborted')); } - function dbQuestionsSuccess(err, databaseConfig) { + var dbQuestionsSuccess = function (err, databaseConfig) { if (!databaseConfig) { return next(new Error('aborted')); } @@ -135,7 +135,7 @@ var async = require('async'), config.bcrypt_rounds = 12; config.upload_path = '/public/uploads'; - config.use_port = (config.use_port.slice(0, 1) === 'y') ? true : false; + config.use_port = config.use_port.slice(0, 1) === 'y'; var urlObject = url.parse(config.base_url), relative_path = (urlObject.pathname && urlObject.pathname.length > 1) ? urlObject.pathname : '', @@ -152,12 +152,20 @@ var async = require('async'), install.save(server_conf, client_conf, function(err) { require('./database').init(next); }); - } + }; if(config.database === 'redis') { - prompt.get(install.redisQuestions, dbQuestionsSuccess); + if (config['redis:host'] && config['redis:port']) { + dbQuestionsSuccess(null, config); + } else { + prompt.get(install.redisQuestions, dbQuestionsSuccess); + } } else if(config.database === 'mongo') { - prompt.get(install.mongoQuestions, dbQuestionsSuccess); + if (config['mongo:host'] && config['mongo:port']) { + dbQuestionsSuccess(null, config); + } else { + prompt.get(install.mongoQuestions, dbQuestionsSuccess); + } } else { return next(new Error('unknown database : ' + config.database)); } @@ -173,9 +181,9 @@ var async = require('async'), } else { // Use provided values, fall back to defaults var config = {}, - question, x, numQ; - for(x=0,numQ=install.questions.length;x