Skip to content

Commit

Permalink
refs #49, #50 - casperjs python executable wasn't passing native phan…
Browse files Browse the repository at this point in the history
…tomjs args in the correct order
  • Loading branch information
n1k0 committed Feb 9, 2012
1 parent f1f4386 commit bfd295f
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions bin/casperjs
Expand Up @@ -10,14 +10,41 @@ def resolve(path):
return resolve(os.readlink(path))
return path

PHANTOMJS_EXEC = os.environ.get('PHANTOMJS_EXECUTABLE', 'phantomjs').split(' ')
PHANTOMJS_NATIVE_ARGS = [
'cookies-file',
'config',
'disk-cache',
'ignore-ssl-errors',
'load-images',
'load-plugins',
'local-to-remote-url-access',
'max-disk-cache-size',
'output-encoding',
'proxy',
'proxy-type',
'script-encoding',
]
CASPER_ARGS = []
PHANTOMJS_ARGS = []

found = False
for arg in sys.argv[1:]:
for native in PHANTOMJS_NATIVE_ARGS:
if arg.startswith('--%s' % native):
PHANTOMJS_ARGS.append(arg)
found = True
if not found:
CASPER_ARGS.append(arg)
found = False

CASPER_PATH = os.path.abspath(os.path.join(os.path.dirname(resolve(__file__)), '..'))
CASPER_ARGS = PHANTOMJS_EXEC
CASPER_ARGS.extend([os.path.join(CASPER_PATH, 'bin', 'bootstrap.js'), '--casper-path=%s' % CASPER_PATH, '--cli'])
CASPER_ARGS.extend(sys.argv[1:])
CASPER_COMMAND = os.environ.get('PHANTOMJS_EXECUTABLE', 'phantomjs').split(' ')
CASPER_COMMAND.extend(PHANTOMJS_ARGS)
CASPER_COMMAND.extend([os.path.join(CASPER_PATH, 'bin', 'bootstrap.js'), '--casper-path=%s' % CASPER_PATH, '--cli'])
CASPER_COMMAND.extend(CASPER_ARGS)

try:
status = subprocess.call(CASPER_ARGS)
status = subprocess.call(CASPER_COMMAND)
except KeyboardInterrupt:
print('\nCasperJS interrupted, exiting.')
status = 0
Expand Down

0 comments on commit bfd295f

Please sign in to comment.