npm install properties-reader --save
mkdir env
process.argv.forEach(function (val, index, array) {
var arg = val.split("=");
if (arg.length > 0) {
if (arg[0] === 'env') {
var env = require('./env/' + arg[1] + '.properties');
module.exports = env;
}
}
});
# Dev properties
[main]
# Application port to run the node server
app.port=8080
[database]
# Database connection to mysql
mysql.host=localhost
mysql.port=2500
...
var enviorment = require('./environments');
var PropertiesReader = require('properties-reader');
var properties = new PropertiesReader(enviorment);
var someVal = properties.get('main.app.port');
npm start env=development
or
npm start env=production