refs #28 - usage of executable shouldn't be mandatory; so welcome to the phantom.casperPath variable
Showing
3 changed files
with
12 additions
and
14 deletions
... | @@ -2,4 +2,4 @@ | ... | @@ -2,4 +2,4 @@ |
2 | 2 | ||
3 | CASPERJS_HOME="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" | 3 | CASPERJS_HOME="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" |
4 | 4 | ||
5 | phantomjs $CASPERJS_HOME/casper.js $CASPERJS_HOME $* | 5 | phantomjs $CASPERJS_HOME/casper.js --casper-dir=$CASPERJS_HOME $* | ... | ... |
... | @@ -32,20 +32,18 @@ | ... | @@ -32,20 +32,18 @@ |
32 | return Array.prototype.join.call(arguments, this.separator); | 32 | return Array.prototype.join.call(arguments, this.separator); |
33 | }; | 33 | }; |
34 | 34 | ||
35 | if (!fs.isDirectory(phantom.args[0]) || !fs.isFile(fs.pathJoin(phantom.args[0], 'casper.js'))) { | 35 | // seeking for casperPath passed as an argument |
36 | console.log('First argument must be the absolute path to casper root path.'); | 36 | phantom.args.forEach(function(arg) { |
37 | phantom.exit(1); | 37 | var pathMatch = arg.match(/--casper-dir=(.+)/); |
38 | if (pathMatch) { | ||
39 | phantom.casperPath = pathMatch[1]; | ||
38 | } | 40 | } |
41 | }); | ||
39 | 42 | ||
40 | if (!fs.isFile(phantom.args[1])) { | 43 | if (!phantom.casperPath || !fs.isDirectory(phantom.casperPath)) { |
41 | console.log('Usage: $ casperjs script.[js|coffee]'); | 44 | console.log('Cannot find CasperJS home path. Did you set phantom.casperPath or pass the --casper-dir option?'); |
42 | phantom.exit(1); | ||
43 | } | 45 | } |
44 | 46 | ||
45 | phantom.casperPath = phantom.args[0]; | ||
46 | phantom.casperScript = phantom.args[1]; | ||
47 | phantom.casperLibPath = fs.pathJoin(phantom.casperPath, 'lib'); | ||
48 | |||
49 | [ | 47 | [ |
50 | 'casper.js', | 48 | 'casper.js', |
51 | 'clientutils.js', | 49 | 'clientutils.js', |
... | @@ -55,7 +53,7 @@ | ... | @@ -55,7 +53,7 @@ |
55 | 'utils.js', | 53 | 'utils.js', |
56 | 'xunit.js' | 54 | 'xunit.js' |
57 | ].forEach(function(lib) { | 55 | ].forEach(function(lib) { |
58 | phantom.injectJs(fs.pathJoin(phantom.casperLibPath, lib)); | 56 | phantom.injectJs(fs.pathJoin(phantom.casperPath, 'lib', lib)); |
59 | }); | 57 | }); |
60 | 58 | ||
61 | phantom.injectJs(phantom.args[1]); | 59 | phantom.injectJs(phantom.args[1]); | ... | ... |
1 | var fs = require('fs'); | 1 | var fs = require('fs'); |
2 | 2 | ||
3 | phantom.injectJs(fs.pathJoin(phantom.casperLibPath, 'vendors', 'esprima.js')); | 3 | phantom.injectJs(fs.pathJoin(phantom.casperPath, 'lib', 'vendors', 'esprima.js')); |
4 | 4 | ||
5 | var casper = new phantom.Casper({ | 5 | var casper = new phantom.Casper({ |
6 | faultTolerant: false, | 6 | faultTolerant: false, |
... | @@ -11,7 +11,7 @@ var tests = []; | ... | @@ -11,7 +11,7 @@ var tests = []; |
11 | if (phantom.args.length > 2 && fs.isFile(phantom.args[2])) { | 11 | if (phantom.args.length > 2 && fs.isFile(phantom.args[2])) { |
12 | tests = [phantom.args[2]]; | 12 | tests = [phantom.args[2]]; |
13 | } else { | 13 | } else { |
14 | tests = [fs.absolute(fs.pathJoin(phantom.casperLibPath, '..', 'tests', 'suites'))]; | 14 | tests = [fs.absolute(fs.pathJoin(phantom.casperPath, 'tests', 'suites'))]; |
15 | } | 15 | } |
16 | 16 | ||
17 | // Overriding Casper.open to prefix all test urls | 17 | // Overriding Casper.open to prefix all test urls | ... | ... |
-
Please register or sign in to post a comment