Commit ca5fdb6a ca5fdb6af87b7dde55f4ff3d0c02b85242377b56 by Nicolas Perriault

say back hello to python exec - see https://groups.google.com/forum/?pli=1#!topi…

…c/phantomjs/7BLZwcBmiIs
1 parent 329b0b7e
#!/usr/bin/env phantomjs
/*!
* Casper is a navigation utility for PhantomJS.
*
......@@ -65,7 +63,15 @@ if (!phantom.casperLoaded) {
})(require('fs'));
// casper root path
phantom.casperPath = fs.absolute(phantom.libraryScript);
// TODO: take --casper-path=.* from python executable
if (!phantom.casperPath) {
phantom.casperPath = fs.absolute(phantom.args.map(function(arg) {
var match = arg.match(/--casper-path=(.*)/i);
if (match) {
return match[1];
}
}).pop());
}
// Embedded, up-to-date, validatable & controlable CoffeeScript
phantom.injectJs(fs.pathJoin(phantom.casperPath, 'modules', 'vendors', 'coffee-script.js'));
......@@ -208,7 +214,7 @@ if (!!phantom.casperArgs.options.version) {
console.log(phantom.casperVersion.toString());
phantom.exit(0);
} else if (phantom.casperArgs.args.length === 0 || !!phantom.casperArgs.options.help) {
console.log('CasperJS version ' + phantom.casperVersion.toString());
console.log('CasperJS version ' + phantom.casperVersion.toString() + ' at ' + phantom.casperPath);
console.log('Usage: casperjs script.(js|coffee) [options...]');
console.log('Read the docs http://n1k0.github.com/casperjs/');
phantom.exit(0);
......
#!/usr/bin/env python
import os
import subprocess
import sys
def resolve(path):
if os.path.islink(path):
return resolve(os.readlink(path))
return path
CASPER_PATH = os.path.abspath(os.path.join(os.path.dirname(resolve(__file__)), '..'))
CASPER_ARGS = ['phantomjs', os.path.join(CASPER_PATH, 'bin', 'bootstrap.js'), '--casper-path=%s' % CASPER_PATH, '--cli']
CASPER_ARGS.extend(sys.argv[1:])
try:
subprocess.call(CASPER_ARGS)
except KeyboardInterrupt:
print '\nCasperJS interrupted, exiting.'
sys.exit()