Skip to content

Commit

Permalink
say back hello to python exec - see https://groups.google.com/forum/?…
Browse files Browse the repository at this point in the history
  • Loading branch information
n1k0 committed Jan 1, 2012
1 parent 329b0b7 commit ca5fdb6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
14 changes: 10 additions & 4 deletions casperjs → bin/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env phantomjs

/*!
* Casper is a navigation utility for PhantomJS.
*
Expand Down Expand Up @@ -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'));
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 21 additions & 0 deletions bin/casperjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/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()

0 comments on commit ca5fdb6

Please sign in to comment.