Created
April 20, 2012 13:47
-
-
Save bigsan/2428805 to your computer and use it in GitHub Desktop.
PowerShell: rewrite casperjs from python to powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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', | |
'remote-debugger-port', | |
'remote-debugger-autorun', | |
'proxy', | |
'proxy-auth', | |
'proxy-type', | |
'script-encoding', | |
'web-security' | |
$CASPER_ARGS = @() | |
$PHANTOMJS_ARGS = @() | |
foreach ($arg in $args) | |
{ | |
[bool] $found = 0 | |
foreach ($native in $PHANTOMJS_NATIVE_ARGS) | |
{ | |
if ($arg.StartsWith("--$native")) | |
{ | |
$PHANTOMJS_ARGS += $arg | |
$found = 1 | |
} | |
} | |
if (!$found) | |
{ | |
$CASPER_ARGS += $arg | |
} | |
} | |
$CASPER_PATH = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Definition) | |
$CASPER_COMMAND_ARGS = $PHANTOMJS_ARGS + @("""$CASPER_PATH\bin\bootstrap.js""", "--casper-path=""$CASPER_PATH""", "--cli") + $CASPER_ARGS | |
$phantomjs = (Get-Command phantomjs).Definition | |
& $phantomjs $CASPER_COMMAND_ARGS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment