node-postgres/test/cli.js

27 lines
808 B
JavaScript
Raw Normal View History

var config = {};
if(process.argv[2]) {
config = require(__dirname + '/../lib/utils').parseConnectionString(process.argv[2]);
}
//TODO use these environment variables in lib/ code
//http://www.postgresql.org/docs/8.4/static/libpq-envars.html
config.host = config.host || process.env['PGHOST'] || process.env['PGHOSTADDR'];
config.port = config.port || process.env['PGPORT'];
config.database = config.database || process.env['PGDATABASE'];
config.user = config.user || process.env['PGUSER'];
config.password = config.password || process.env['PGPASSWORD'];
2010-10-25 14:30:14 +08:00
2012-05-31 11:12:14 +08:00
for(var i = 0; i < process.argv.length; i++) {
switch(process.argv[i].toLowerCase()) {
case 'native':
config.native = true;
2010-10-25 14:30:14 +08:00
break;
2012-05-31 11:12:14 +08:00
case 'binary':
config.binary = true;
2010-10-25 14:30:14 +08:00
break;
default:
break;
}
}
module.exports = config;