diff --git a/app.js b/app.js index c338878..5599845 100644 --- a/app.js +++ b/app.js @@ -7,25 +7,28 @@ var bodyParser = require('body-parser'); var ejs = require('ejs'); var fs = require('fs'); -if (!process.env.NODE_ENV) +if (!process.env.NODE_ENV) { process.env.NODE_ENV = 'dev'; - -var mode = 'dev'; -var prodArg = false; -for (var i in process.argv) { - if (process.argv[i] == '--prod') - prodArg = true; + var mode = 'dev'; } -if (process.env.NODE_ENV == 'dev' || process.env.NODE_ENV == 'development') { +for (var i in process.argv) { + if (process.argv.hasOwnProperty(i)) { + if (process.argv[i] == '--prod') { + mode = 'prod' + } + } +} + +if (mode == 'dev') { console.log('server run as development mode'); global.Connections = require('./config/conn.dev.js'); } -if (process.env.NODE_ENV == 'prod' || process.env.NODE_ENV == 'production' || prodArg) { +if (mode == 'prod') { console.log('server run as production mode'); global.Connections = require('./config/conn.prod.js'); - mode = 'prod'; + } var app = express();