From b1bb492a220f9357f3e3730ef58137301da3fc47 Mon Sep 17 00:00:00 2001 From: li-qiang Date: Mon, 25 Jan 2016 19:34:45 +0800 Subject: [PATCH 1/3] Fix bug for windows path --- lib/Utilities.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Utilities.js b/lib/Utilities.js index f5164b90..52c806cb 100644 --- a/lib/Utilities.js +++ b/lib/Utilities.js @@ -283,8 +283,8 @@ exports.getRealPath = function (path_str, stack_index) { cwd = path.dirname(m[1]); } - if (path_str[0] !== path.sep) { - path_str = cwd + "/" + path_str; + if (!path.isAbsolute(path_str)) { + path_str = path.join(cwd, path_str); } if (path_str.substr(-1) === path.sep) { path_str += "index"; From c6c895b80bd1316828773ccf5a30c6ca23eba8f2 Mon Sep 17 00:00:00 2001 From: li-qiang Date: Mon, 25 Jan 2016 19:59:41 +0800 Subject: [PATCH 2/3] Fix test for path isAbsolute --- lib/Utilities.js | 3 ++- package.json | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Utilities.js b/lib/Utilities.js index 52c806cb..6c2fb4b3 100644 --- a/lib/Utilities.js +++ b/lib/Utilities.js @@ -271,6 +271,7 @@ exports.convertPropToJoinKeyProp = function (props, opts) { exports.getRealPath = function (path_str, stack_index) { var path = require("path"); // for now, load here (only when needed) + var pathIsAbsolute = require('path-is-absolute'); var cwd = process.cwd(); var err = new Error(); var tmp = err.stack.split(/\r?\n/)[typeof stack_index !== "undefined" ? stack_index : 3], m; @@ -283,7 +284,7 @@ exports.getRealPath = function (path_str, stack_index) { cwd = path.dirname(m[1]); } - if (!path.isAbsolute(path_str)) { + if (!pathIsAbsolute(path_str)) { path_str = path.join(cwd, path_str); } if (path_str.substr(-1) === path.sep) { diff --git a/package.json b/package.json index 64452897..0a5997ff 100644 --- a/package.json +++ b/package.json @@ -36,11 +36,12 @@ }, "analyse" : false, "dependencies": { - "enforce" : "0.1.6", - "sql-query" : "0.1.26", - "sql-ddl-sync" : "0.3.11", - "hat" : "0.0.3", - "lodash" : "2.4.1" + "enforce" : "0.1.6", + "sql-query" : "0.1.26", + "sql-ddl-sync" : "0.3.11", + "hat" : "0.0.3", + "lodash" : "2.4.1", + "path-is-absolute" : "1.0.0" }, "devDependencies": { "mysql" : "2.9.0", From 45dde7bb465fe57849f61783b9242ef0317ede58 Mon Sep 17 00:00:00 2001 From: li-qiang Date: Mon, 25 Jan 2016 20:10:56 +0800 Subject: [PATCH 3/3] select funtion for path absolute --- lib/Utilities.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Utilities.js b/lib/Utilities.js index 6c2fb4b3..e3c9859b 100644 --- a/lib/Utilities.js +++ b/lib/Utilities.js @@ -271,7 +271,6 @@ exports.convertPropToJoinKeyProp = function (props, opts) { exports.getRealPath = function (path_str, stack_index) { var path = require("path"); // for now, load here (only when needed) - var pathIsAbsolute = require('path-is-absolute'); var cwd = process.cwd(); var err = new Error(); var tmp = err.stack.split(/\r?\n/)[typeof stack_index !== "undefined" ? stack_index : 3], m; @@ -283,7 +282,7 @@ exports.getRealPath = function (path_str, stack_index) { } else if ((m = tmp.match(/^\s*at\s+.+\s+\((.+):\d+:\d+\)$/)) !== null) { cwd = path.dirname(m[1]); } - + var pathIsAbsolute = path.isAbsolute || require('path-is-absolute'); if (!pathIsAbsolute(path_str)) { path_str = path.join(cwd, path_str); }