mysql-ssh
Advanced tools
Comparing version 1.0.5 to 1.0.6
20
mysql.js
@@ -12,5 +12,13 @@ #!/usr/bin/env node | ||
/** | ||
* @var ssh2.Connection _conn The SSH connection | ||
*/ | ||
_conn: null, | ||
/** | ||
* @var mysql2.Connection _conn The MySQL connection | ||
*/ | ||
_sql: null, | ||
/** | ||
* @param obj sshConfig SSH Configuration as defined by ssh2 package | ||
@@ -32,7 +40,7 @@ * @param obj dbConfig MySQL Configuration as defined by mysql(2) package | ||
if (err) { | ||
tunnel._conn.end() | ||
tunnel.close() | ||
var msg = err.reason == 'CONNECT_FAILED' | ||
? 'Connection failed.' | ||
: err | ||
return reject(err) | ||
return reject(msg) | ||
} | ||
@@ -44,4 +52,4 @@ | ||
var sql = mysql.createConnection(dbConfig) | ||
resolve(sql) | ||
tunnel._sql = mysql.createConnection(dbConfig) | ||
resolve(tunnel._sql) | ||
} | ||
@@ -54,2 +62,6 @@ ) | ||
close: function() { | ||
if ('end' in tunnel._sql) { | ||
tunnel._sql.end(function(err) {}) | ||
} | ||
if ('end' in tunnel._conn) { | ||
@@ -56,0 +68,0 @@ tunnel._conn.end() |
@@ -9,3 +9,3 @@ { | ||
"name": "mysql-ssh", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Execute mysql commands over an ssh tunnel.", | ||
@@ -12,0 +12,0 @@ "main": "mysql.js", |
11399
67