2020-04-19 07:31:44 -04:00
|
|
|
var fs = require('fs');
|
2016-10-04 22:58:05 -04:00
|
|
|
var path = require('path');
|
2020-04-19 07:31:44 -04:00
|
|
|
const envs = ['development', 'test', 'production'];
|
|
|
|
|
|
|
|
if (!fs.existsSync(path.resolve('config'))) {
|
|
|
|
fs.mkdirSync(path.resolve('config'));
|
|
|
|
}
|
|
|
|
|
|
|
|
const configJson = JSON.parse(fs.readFileSync('config.json'));
|
|
|
|
|
|
|
|
let database = {};
|
|
|
|
envs.forEach(function (env, i) {
|
|
|
|
if (configJson[env]) {
|
|
|
|
database[env] = {
|
|
|
|
...configJson[env].db
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
fs.writeFile(path.resolve('config', 'database.json'), JSON.stringify(database), 'utf8', function (err) {
|
|
|
|
if (err) {
|
|
|
|
console.log("An error occured while writing JSON Object to File.");
|
|
|
|
return console.log(err);
|
|
|
|
}
|
|
|
|
});
|
2016-10-04 22:58:05 -04:00
|
|
|
|
|
|
|
module.exports = {
|
2020-04-19 07:31:44 -04:00
|
|
|
'config': path.resolve('config', 'database.json'),
|
2020-05-22 08:15:45 -04:00
|
|
|
'migrations-path': path.resolve('src/lib', 'migrations'),
|
|
|
|
'models-path': path.resolve('src/lib', 'models')
|
2020-04-19 07:31:44 -04:00
|
|
|
}
|