browser-run2
The easiest way of running code in a browser environment.
Same as juliangruber/browser-run, but uses benderjs/browser-launcher2 instead of substack/browser-launcher, due to substack/browser-launcher/issues/34.
Installation
$ npm install browser-run2 # for library $ npm install -g browser-run2 # for cli
Usage
$ echo "console.log('Hey there from ' + document.location)" | browser-runHey there from http://localhost:53227/
Or use browser-run
programmatically:
var run = ; var browser = ;browser;browser;browser;
Example with browserify
$ browserify main.js | browser-run
or
var browserify = ;var browser = ; ;
CLI
$ browser-run --helpRun JavaScript in a browser.Write code to stdin and receive console output on stdout.Usage: browser-run [OPTIONS] Options: --browser, -b Browser to use. Available
API
run([opts])
Returns a duplex stream and starts a webserver.
opts
can be:
port
: If speficied, no browser will be started, so you can point one yourself tohttp://localhost/<port>
browser
: Browser to use. Defaults tophantom
. Available if installed:chrome
firefox
ie
phantom
safari
run#stop()
Stop the underlying webserver.
License
MIT