diff --git a/Readme.md b/Readme.md index fe92cb4..c729398 100644 --- a/Readme.md +++ b/Readme.md @@ -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 diff --git a/phantom-bootstrap.js b/phantom-bootstrap.js index f982b5d..ca21620 100644 --- a/phantom-bootstrap.js +++ b/phantom-bootstrap.js @@ -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)) }) diff --git a/phantomify.js b/phantomify.js index af4ad72..3e9cc7b 100644 --- a/phantomify.js +++ b/phantomify.js @@ -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) {