Commit 67db3a36 67db3a36d229438b13c64138b3caa86974589437 by hexid

Create setScriptBaseDir(scriptName) to fix jshint tests

1 parent ecb8b67e
...@@ -227,17 +227,21 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); ...@@ -227,17 +227,21 @@ CasperError.prototype = Object.getPrototypeOf(new Error());
227 function initCasperCli(casperArgs) { 227 function initCasperCli(casperArgs) {
228 var baseTestsPath = fs.pathJoin(phantom.casperPath, 'tests'); 228 var baseTestsPath = fs.pathJoin(phantom.casperPath, 'tests');
229 229
230 function setScriptBaseDir(scriptName) {
231 var dir = fs.dirname(scriptName);
232 if(dir === scriptName) {
233 dir = '.';
234 }
235 phantom.casperScriptBaseDir = dir;
236 }
237
230 if (!!casperArgs.options.version) { 238 if (!!casperArgs.options.version) {
231 return __terminate(phantom.casperVersion.toString()) 239 return __terminate(phantom.casperVersion.toString())
232 } else if (casperArgs.get(0) === "test") { 240 } else if (casperArgs.get(0) === "test") {
233 phantom.casperScript = fs.absolute(fs.pathJoin(baseTestsPath, 'run.js')); 241 phantom.casperScript = fs.absolute(fs.pathJoin(baseTestsPath, 'run.js'));
234 phantom.casperTest = true; 242 phantom.casperTest = true;
235 casperArgs.drop("test"); 243 casperArgs.drop("test");
236 var scriptDir = fs.dirname(casperArgs.get(0)); 244 setScriptBaseDir(casperArgs.get(0));
237 if (scriptDir === casperArgs.get(0)) {
238 scriptDir = '.';
239 }
240 phantom.casperScriptBaseDir = scriptDir;
241 } else if (casperArgs.get(0) === "selftest") { 245 } else if (casperArgs.get(0) === "selftest") {
242 phantom.casperScript = fs.absolute(fs.pathJoin(baseTestsPath, 'run.js')); 246 phantom.casperScript = fs.absolute(fs.pathJoin(baseTestsPath, 'run.js'));
243 phantom.casperSelfTest = phantom.casperTest = true; 247 phantom.casperSelfTest = phantom.casperTest = true;
...@@ -260,11 +264,7 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); ...@@ -260,11 +264,7 @@ CasperError.prototype = Object.getPrototypeOf(new Error());
260 } 264 }
261 265
262 if (!phantom.casperScriptBaseDir) { 266 if (!phantom.casperScriptBaseDir) {
263 var scriptDir = fs.dirname(phantom.casperScript); 267 setScriptBaseDir(phantom.casperScript);
264 if (scriptDir === phantom.casperScript) {
265 scriptDir = '.';
266 }
267 phantom.casperScriptBaseDir = fs.absolute(scriptDir);
268 } 268 }
269 269
270 // filter out the called script name from casper args 270 // filter out the called script name from casper args
......