diff --git a/config.json.example b/config/config.json.example similarity index 100% rename from config.json.example rename to config/config.json.example diff --git a/test_config.json.example b/config/test_config.json.example similarity index 100% rename from test_config.json.example rename to config/test_config.json.example diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 3a61dacebd8b3fbb5228f258a536f734c974a840..66bc5000609af2508f23ec6e8795db1dd122d560 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -46,10 +46,10 @@ gulp.task('compile', () => { .pipe(gulp.dest('build')); // move compiled files to build directory // copy configuration file to build directory - gulp.src('config.json') - .pipe(gulp.dest('build')); - gulp.src('test_config.json') - .pipe(gulp.dest('build')); + gulp.src('config/config.json') + .pipe(gulp.dest('build/config')); + gulp.src('config/test_config.json') + .pipe(gulp.dest('build/config')); }); gulp.task('build', ['compile']); diff --git a/src/libs/config.js b/src/libs/config.js index dd2d88c48ccbd82fc1524b361ceee6321c985054..d61eff9958f13d08770493a1b477b6110c74ebff 100644 --- a/src/libs/config.js +++ b/src/libs/config.js @@ -1,16 +1,17 @@ const nconf = require('nconf'); +const CONFIG_DIR = `config` let config_file; switch(process.env.NODE_ENV) { case 'development': - config_file = 'config.json'; + config_file = `${CONFIG_DIR}/config.json`; break; case 'test': - config_file = 'test_config.json'; + config_file = `${CONFIG_DIR}/test_config.json`; break; case 'production': - config_file = 'config.json'; + config_file = `${CONFIG_DIR}/config.json`; break; } @@ -19,6 +20,4 @@ nconf.argv() .env() .file({ file: `${process.cwd()}/${config_file}` }); -console.log(nconf.get('mongodb')); - module.exports = nconf;