1 Star 0 Fork 11

李杨 / mysqldiff

forked from hcxiong / mysqldiff 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Tools.js 1.04 KB
一键复制 编辑 原始数据 按行查看 历史
xionghc 提交于 2017-01-03 14:50 . bug
var cp = require('child_process');
exports.exec = function (cmd, option) {
return new Promise(function(resolve, reject) {
cp.exec(cmd, option, function(err, stdout, stderr) {
resolve(err ? err.message : stdout);
});
});
}
exports.dbConfig = function(config) {
var index1 = config.indexOf(':');
var index2 = config.lastIndexOf('@');
var index3 = config.lastIndexOf('~');
var index4 = config.lastIndexOf('#');
if (index1 == -1 || index2 == -1 || index3 == -1) return;
if (index4 == -1 || index4<index2) index4 = config.length;
var user = config.substring(0, index1);
var password = config.substring(index1+1, index2);
var host = config.substring(index2+1, index3);
var database = config.substring(index3+1, index4);
var port = config.substring(index4+1);
return {
'host': host,
'port': !port ? 3306 : parseInt(port),
'user': user,
'password': password,
'database': database
};
}
exports.rand = function(min, max) {
return min + Math.round(Math.random()*(max-min));
}
exports.randPort = function() {
return exports.rand(32000, 35000);
}
NodeJS
1
https://gitee.com/drdstd_330937205/mysqldiff.git
git@gitee.com:drdstd_330937205/mysqldiff.git
drdstd_330937205
mysqldiff
mysqldiff
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891