不要怂,就是干,撸起袖子干!

Commit b8e584d7 by Sascha Depold

added config for production/development/test and use development config by default

1 parent 9f1eacd2
Showing with 17 additions and 6 deletions
...@@ -52,9 +52,12 @@ var createMigrationsFolder = function(force) { ...@@ -52,9 +52,12 @@ var createMigrationsFolder = function(force) {
var readConfig = function() { var readConfig = function() {
try { try {
var config = JSON.parse(fs.readFileSync(configFile)) var config = JSON.parse(fs.readFileSync(configFile))
if (config[process.env.NODE_ENV]) { , env = process.env.NODE_ENV || 'development'
config = config[process.env.NODE_ENV]
if (config[env]) {
config = config[env]
} }
return config return config
} catch(e) { } catch(e) {
throw new Error('The config.json is not available or contains invalid JSON.') throw new Error('The config.json is not available or contains invalid JSON.')
...@@ -106,14 +109,22 @@ if(program.migrate) { ...@@ -106,14 +109,22 @@ if(program.migrate) {
} else if(program.init) { } else if(program.init) {
if(!configFileExists || !!program.force) { if(!configFileExists || !!program.force) {
writeConfig({ writeConfig({
development: {
username: "root", username: "root",
password: null, password: null,
database: 'database', database: 'database_development',
host: '127.0.0.1', host: '127.0.0.1'
development: { },
test: {
username: "root",
password: null,
database: 'database_test',
host: '127.0.0.1'
},
production: {
username: "root", username: "root",
password: null, password: null,
database: 'database', database: 'database_production',
host: '127.0.0.1' host: '127.0.0.1'
} }
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!