Permalink
Browse files

Add support for second url argument.

  • Loading branch information...
1 parent 061a8aa commit cce2ad58659df232e5fb50c4c3c4fdbb67c56556 @Gozala committed Nov 2, 2012
Showing with 13 additions and 5 deletions.
  1. +10 −2 Readme.md
  2. +1 −2 phantom-bootstrap.js
  3. +2 −1 phantomify.js
View
@@ -13,10 +13,18 @@ let you run node module in a headless browser environment.
## Usage
- phantomify ./path/to/index.js
+ phantomify ./path/to/module.js
[Phantomify][] will make a browserify bundle for the given module path
-and then will load & execute it in an empty HTML page in a [PhantomJS][].
+and then will load & execute it in an empty "about:blank" page in a
+[PhantomJS][].
+
+
+Sometimes "about:blank" is just not good enough there for [Phantomify][]
+can be given second argument for the page URL where code should be executed:
+
+ phantomify ./path/to/module.js http://localhost:8080/
+
## Install
View
@@ -24,8 +24,7 @@ page.onClosing = function(closingPage) {
var code = closingPage.url.split("#")[1]
phantom.exit(code && parseInt(code))
}
-page.open("about:blank", function onPage(status) {
- console.log(system.args[1])
+page.open(system.args[2] || "about:blank", function onPage(status) {
var source = fs.read(system.args[1])
page.evaluateAsync(Function(source))
})
View
@@ -149,7 +149,8 @@ function phantomify(main) {
if (bundle.ok) {
fs.writeFileSync(file, source)
- var phantomjs = spawn("phantomjs", [ bootstrap, file ], {
+ var args = [ bootstrap, file ].concat(process.argv.slice(3))
+ var phantomjs = spawn("phantomjs", args, {
stdio: "inherit"
})
phantomjs.once("exit", function(code) {

0 comments on commit cce2ad5

Please sign in to comment.