Commit 6e38aa26 6e38aa265f6cd1f2631c3db6754961ec612d246f by Nicolas Perriault

refs #28 - usage of executable shouldn't be mandatory; so welcome to the phantom.casperPath variable

1 parent de6db3a4
......@@ -2,4 +2,4 @@
CASPERJS_HOME="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
phantomjs $CASPERJS_HOME/casper.js $CASPERJS_HOME $*
phantomjs $CASPERJS_HOME/casper.js --casper-dir=$CASPERJS_HOME $*
......
......@@ -32,20 +32,18 @@
return Array.prototype.join.call(arguments, this.separator);
};
if (!fs.isDirectory(phantom.args[0]) || !fs.isFile(fs.pathJoin(phantom.args[0], 'casper.js'))) {
console.log('First argument must be the absolute path to casper root path.');
phantom.exit(1);
// seeking for casperPath passed as an argument
phantom.args.forEach(function(arg) {
var pathMatch = arg.match(/--casper-dir=(.+)/);
if (pathMatch) {
phantom.casperPath = pathMatch[1];
}
});
if (!fs.isFile(phantom.args[1])) {
console.log('Usage: $ casperjs script.[js|coffee]');
phantom.exit(1);
if (!phantom.casperPath || !fs.isDirectory(phantom.casperPath)) {
console.log('Cannot find CasperJS home path. Did you set phantom.casperPath or pass the --casper-dir option?');
}
phantom.casperPath = phantom.args[0];
phantom.casperScript = phantom.args[1];
phantom.casperLibPath = fs.pathJoin(phantom.casperPath, 'lib');
[
'casper.js',
'clientutils.js',
......@@ -55,7 +53,7 @@
'utils.js',
'xunit.js'
].forEach(function(lib) {
phantom.injectJs(fs.pathJoin(phantom.casperLibPath, lib));
phantom.injectJs(fs.pathJoin(phantom.casperPath, 'lib', lib));
});
phantom.injectJs(phantom.args[1]);
......
var fs = require('fs');
phantom.injectJs(fs.pathJoin(phantom.casperLibPath, 'vendors', 'esprima.js'));
phantom.injectJs(fs.pathJoin(phantom.casperPath, 'lib', 'vendors', 'esprima.js'));
var casper = new phantom.Casper({
faultTolerant: false,
......@@ -11,7 +11,7 @@ var tests = [];
if (phantom.args.length > 2 && fs.isFile(phantom.args[2])) {
tests = [phantom.args[2]];
} else {
tests = [fs.absolute(fs.pathJoin(phantom.casperLibPath, '..', 'tests', 'suites'))];
tests = [fs.absolute(fs.pathJoin(phantom.casperPath, 'tests', 'suites'))];
}
// Overriding Casper.open to prefix all test urls
......