browser-run alternatives and similar modules
Based on the "Command Line Apps" category.
Alternatively, view browser-run alternatives based on common mentions on social networks and blogs.
-
Standard
🌟 JavaScript Style Guide, with linter & automatic code fixer -
ignite
Infinite Red's battle-tested React Native project boilerplate, along with a CLI, component/model generators, and more! -
XO
❤️ JavaScript/TypeScript linter (ESLint wrapper) with great defaults -
Live Server
A simple development http server with live reload capability. -
speed-test
Test your internet connection speed and ping using speedtest.net from the CLI -
Open Source CRM
Building a modern alternative to Salesforce. -
rtail
rtail(1) - Terminal output to the browser in seconds, using UNIX pipes. -
David
:eyeglasses: Node.js module that tells you when your package npm dependencies are out of date. -
diff2html-cli
Pretty diff to html javascript cli (diff2html-cli) -
Whatspup
:white_square_button: WhatsApp chat from commandline/console/cli using GoogleChrome puppeteer -
pjs
Pipeable javascript. Quickly filter, map, and reduce from the terminal -
kill-tabs
Kill all Chrome tabs to improve performance, decrease battery usage, and save memory -
tty-table
Terminal table for Windows, Linux, and MacOS. Written in nodejs. Also works in browser console. Word wrap, padding, alignment, colors, Asian character support, per-column callbacks, and you can pass rows as objects or arrays. Backwards compatible with Automattic/cli-table. -
normit
Translations with speech synthesis in your terminal as a node package -
npm-name
Check whether a package or organization name is available on npm
Appwrite - The open-source backend cloud platform
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of browser-run or a related project?
README
browser-run
The easiest way of running code in a browser environment.
Bundles electronjs
by default!
Usage
$ echo "console.log('Hey from ' + location); window.close()" | browser-run
Hey from http://localhost:53227/
$
Or use browser-run
programmatically:
var run = require('browser-run');
var browser = run();
browser.pipe(process.stdout);
browser.end('console.log(location); window.close()');
Example with browserify
$ browserify main.js | browser-run
or
var browserify = require('browserify');
var browser = require('browser-run');
browserify('main.js').bundle().pipe(browser()).pipe(process.stdout);
CLI
$ browser-run --help
Run JavaScript in a browser.
Write code to stdin and receive console output on stdout.
Usage: browser-run [OPTIONS]
Options:
--browser, -b Browser to use. Always available: electron. Available if installed: chrome, firefox, ie, safari [default: "electron"]
--port Starts listening on that port and waits for you to open a browser
--static Serve static assets from this directory
--mock Path to code to handle requests for mocking a dynamic back-end
--input Input type. Defaults to 'javascript', can be set to 'html'.
--node Enable nodejs apis in electron
--basedir Set this if you need to require node modules in node mode
--help Print help
Custom html file
By using --input html
or { input: 'html' }
you can provide a custom html file for browser-run to use. Keep in mind though that it always needs to have <script src="/reporter.js"></script>
above other script tags so browser-run is able to properly forward your console.log
s etc to the terminal.
Dynamic back-end mock
By using --mock mock.js
or { mock: 'mock.js'}
you can provide a custom server-side implementation and handle all requests that are sent to paths beginning with /mock
mock.js needs to export a function that accepts req
and res
arguments for handling requests.
Example:
module.exports = function(req,res){
if (req.url === '/mock/echo') {
req.pipe(res)
}
}
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 toelectron
. Available if installed:chrome
firefox
ie
safari
static
: Serve static files from this directorymock
: Path to code to handle requests for mocking a dynamic back-endinput
: Input type. Defaults tojavascript
, can be set tohtml
.node
: Enable nodejs integration in electronbasedir
: Set this if you need to require node modules innode
mode
If only an empty string is written to it, an error will be thrown as there is nothing to execute.
If you call window.close()
inside the script, the browser will exit.
run#stop()
Stop the underlying webserver.
Headless testing
In environments without a screen, you can use Xvfb
to simulate one.
GitHub Actions
This is a full example to run npm test
. Refer to the last 2 lines in the YAML config:
on:
- pull_request
- push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: npm install
- run: sudo apt-get install xvfb
- run: xvfb-run --auto-servernum npm test
Travis
Add this to your travis.yml:
addons:
apt:
packages:
- xvfb
install:
- export DISPLAY=':99.0'
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- npm install
Any gnu/linux box
$ sudo apt-get install xvfb # or equivalent
$ export DISPLAY=':99.0'
$ Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
$ browser-run ...
Docker
There is also an example Docker image. Source
Installation
With npm do
$ npm install browser-run # for library
$ npm install -g browser-run # for cli
Sponsors
This module is proudly supported by my Sponsors!
Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my Patreon. Not sure how much of my modules you're using? Try feross/thanks!
License
(MIT)
*Note that all licence references and agreements mentioned in the browser-run README section above
are relevant to that project's source code only.