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

Commit edeff6e7 by Simon Townsend

using node url lib for parsing

1 parent 8c1ac604
Showing with 14 additions and 15 deletions
......@@ -6,7 +6,7 @@ var path = require("path")
, Sequelize = require(__dirname + '/../index')
, moment = require("moment")
, _ = Sequelize.Utils._
, parseDatabaseUrl = require('parse-database-url')
, url = require("url")
var configuration = {
configFile: process.cwd() + '/config/config.json',
......@@ -87,20 +87,20 @@ var createMigrationsFolder = function(force) {
}
}
var parseDbUrl = function(url) {
var parseDbUrl = function(urlString) {
var parsed,
config;
config = {};
try {
parsed = parseDatabaseUrl(url);
//var dialect = parsed.driver == 'postgrest' ? 'pg' : parsed.driver;
config = {
username : parsed.user || null,
password : parsed.password || null,
database : parsed.database || null,
host : parsed.host || null,
port : parsed.port || null,
dialect : parsed.driver || null
urlParts = url.parse(urlString)
config.database = urlParts.path.replace(/^\//, '');
config.dialect = urlParts.protocol;
config.dialect = config.dialect.replace(/:$/, '');
config.host = urlParts.hostname;
config.port = urlParts.port;
if (urlParts.auth) {
config.username = urlParts.auth.split(':')[0]
config.password = urlParts.auth.split(':')[1]
}
} catch (e) {
throw new Error('Error parsing url: ' + url);
......
......@@ -48,8 +48,7 @@
"sql": "~0.31.0",
"circular-json": "~0.1.5",
"bluebird": "~0.11.5",
"node-uuid": "~1.4.1",
"parse-database-url": "~0.2.0"
"node-uuid": "~1.4.1"
},
"devDependencies": {
"sqlite3": "~2.1.12",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!