Commit 7d88a761 7d88a761df028712e2a7e994b48fd31e1a7c79ef by Nicolas Perriault

fixed casper could not be used without the executable

1 parent 27398293
......@@ -263,24 +263,16 @@ phantom.loadCasper = function() {
phantom.casperLoaded = true;
};
if (!phantom.casperLoaded) {
try {
phantom.loadCasper();
} catch (e) {
console.error("Unable to load casper environment: " + e);
phantom.exit();
}
}
phantom.initCasperCli = function() {
var fs = require("fs");
var fs = require("fs");
if (!!phantom.casperArgs.options.version) {
if (!!phantom.casperArgs.options.version) {
console.log(phantom.casperVersion.toString());
phantom.exit(0);
} else if (phantom.casperArgs.get(0) === "test") {
} else if (phantom.casperArgs.get(0) === "test") {
phantom.casperScript = fs.absolute(fs.pathJoin(phantom.casperPath, 'tests', 'run.js'));
phantom.casperArgs.drop("test");
} else if (phantom.casperArgs.args.length === 0 || !!phantom.casperArgs.options.help) {
} else if (phantom.casperArgs.args.length === 0 || !!phantom.casperArgs.options.help) {
var phantomVersion = [phantom.version.major, phantom.version.minor, phantom.version.patch].join('.');
var f = require("utils").format;
console.log(f('CasperJS version %s at %s, using PhantomJS version %s',
......@@ -288,23 +280,39 @@ if (!!phantom.casperArgs.options.version) {
phantom.casperPath, phantomVersion));
console.log(fs.read(fs.pathJoin(phantom.casperPath, 'bin', 'usage.txt')));
phantom.exit(0);
}
}
if (!phantom.casperScript) {
if (!phantom.casperScript) {
phantom.casperScript = phantom.casperArgs.get(0);
}
}
if (!fs.isFile(phantom.casperScript)) {
if (!fs.isFile(phantom.casperScript)) {
console.error('Unable to open file: ' + phantom.casperScript);
phantom.exit(1);
}
}
// filter out the called script name from casper args
phantom.casperArgs.drop(phantom.casperScript);
// passed casperjs script execution
try {
// filter out the called script name from casper args
phantom.casperArgs.drop(phantom.casperScript);
// passed casperjs script execution
try {
new Function(phantom.getScriptCode(phantom.casperScript))();
} catch (e) {
} catch (e) {
phantom.processScriptError(e, phantom.casperScript);
}
};
if (!phantom.casperLoaded) {
try {
phantom.loadCasper();
} catch (e) {
console.error("Unable to load casper environment: " + e);
phantom.exit();
}
}
if (true === phantom.casperArgs.get('cli')) {
phantom.initCasperCli();
}
......