less agressively fix fs.dirname() issue
Showing
1 changed file
with
6 additions
and
3 deletions
... | @@ -108,8 +108,7 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); | ... | @@ -108,8 +108,7 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); |
108 | } | 108 | } |
109 | if (!fs.hasOwnProperty('dirname')) { | 109 | if (!fs.hasOwnProperty('dirname')) { |
110 | fs.dirname = function dirname(path) { | 110 | fs.dirname = function dirname(path) { |
111 | var dir = path.replace(/\\/g, '/').replace(/\/[^\/]*$/, ''); | 111 | return path.replace(/\\/g, '/').replace(/\/[^\/]*$/, ''); |
112 | return dir === path ? '.' : dir; | ||
113 | }; | 112 | }; |
114 | } | 113 | } |
115 | if (!fs.hasOwnProperty('isWindows')) { | 114 | if (!fs.hasOwnProperty('isWindows')) { |
... | @@ -239,7 +238,11 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); | ... | @@ -239,7 +238,11 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); |
239 | } | 238 | } |
240 | 239 | ||
241 | if (!phantom.casperScriptBaseDir) { | 240 | if (!phantom.casperScriptBaseDir) { |
242 | phantom.casperScriptBaseDir = fs.absolute(fs.dirname(phantom.casperScript)); | 241 | var scriptDir = fs.dirname(phantom.casperScript); |
242 | if (scriptDir === phantom.casperScript) { | ||
243 | scriptDir = '.'; | ||
244 | } | ||
245 | phantom.casperScriptBaseDir = fs.absolute(scriptDir); | ||
243 | } | 246 | } |
244 | 247 | ||
245 | // filter out the called script name from casper args | 248 | // filter out the called script name from casper args | ... | ... |
-
Please register or sign in to post a comment