# @dxos/browser-runner

> CLI to run JavaScript files into a headless browser.

Latest version **1.0.0-beta.13** (published 2020-07-14) · GPL-3.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @dxos/browser-runner
pnpm add @dxos/browser-runner
yarn add @dxos/browser-runner
bun add @dxos/browser-runner
```

Provides the command `browser-runner`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0-beta.13 |
| Published | 2020-07-14 |
| First published | 2020-05-11 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 15 |
| Unpacked size | 70 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | ashwinp, chrisdxos, dboreham, dxosbuilder, egorgripasov, elmasse, estebanprimost, jozwiaczek_ethworks, marik_d, richburdon, rzad-p, telackey, tinchoz49 |

## Links

- npm: https://www.npmjs.com/package/@dxos/browser-runner
- Repository: https://github.com/dxos/browser-runner
- Homepage: https://github.com/dxos/browser-runner#readme
- Issues: https://github.com/dxos/browser-runner/issues
- npm.io page: https://npm.io/package/@dxos/browser-runner

## Dependencies (15)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [tempy](https://npm.io/package/tempy.md) ^0.5.0
- [yargs](https://npm.io/package/yargs.md) ^15.3.1
- [p-limit](https://npm.io/package/p-limit.md) ^2.3.0
- [webpack](https://npm.io/package/webpack.md) ^4.43.0
- [get-port](https://npm.io/package/get-port.md) ^5.1.1
- [puppeteer](https://npm.io/package/puppeteer.md) ^3.0.4
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.4.5
- [http-server](https://npm.io/package/http-server.md) ^0.12.3
- [babel-loader](https://npm.io/package/babel-loader.md) ^8.1.0
- [serve-handler](https://npm.io/package/serve-handler.md) ^6.1.2
- [dotenv-webpack](https://npm.io/package/dotenv-webpack.md) ^1.7.0
- [source-map-support](https://npm.io/package/source-map-support.md) ^0.5.12
- [html-webpack-plugin](https://npm.io/package/html-webpack-plugin.md) ^4.3.0
- [webpack-inject-plugin](https://npm.io/package/webpack-inject-plugin.md) ^1.5.4

## Recent versions

- 1.0.0-beta.13 (latest) — 2020-07-14
- 1.0.0-beta.9 (beta) — 2020-06-16
- 1.0.0-beta.12 — 2020-07-13
- 1.0.0-beta.11 — 2020-07-13
- 1.0.0-beta.10 — 2020-07-08
- 1.0.0-beta.8 — 2020-06-02
- 1.0.0-beta.7 — 2020-05-26
- 1.0.0-beta.6 — 2020-05-25
- 1.0.0-beta.5 — 2020-05-25
- 1.0.0-beta.4 — 2020-05-14
- 1.0.0-beta.3 — 2020-05-11
- 1.0.0-beta.2 — 2020-05-11
- 1.0.0-beta.1 — 2020-05-11
- 1.0.0-beta.0 — 2020-05-11

## README

# @dxos/browser-runner

> CLI to run JavaScript files into a headless browser.

[![Build Status](https://travis-ci.com/dxos/browser-runner.svg?branch=master)](https://travis-ci.com/dxos/browser-runner)
[![Coverage Status](https://coveralls.io/repos/github/dxos/browser-runner/badge.svg?branch=master)](https://coveralls.io/github/dxos/browser-runner?branch=master)
[![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat-square)](https://github.com/standard/semistandard)
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)

## Install

```
$ npm install -g @dxos/browser-runner
```

## Usage

```
$ browser-runner --help

cli.js <file> [options] [puppeteerOptions]

runs the script

Positionals:
  file  the file to run                                                 [string]

Options:
  --help        Show help                                              [boolean]
  --version     Show version number                                    [boolean]
  --config, -c  webpack config                                          [string]
  --watch, -w   watch                                                  [boolean]
  --port, -p    port to run                                             [number]
  --env         env file                                                [string]
```

### Testing in Chrome

```
$ browser-runner script.js
```

### Testing in Firefox (experimental)

You can test with Firefox using the puppeteer option `product`.

```
$ browser-runner script.js --product firefox
```

Important: First time the execution will take longer since it has to download the firefox browser.

### Process exit

`browser-runner` cannot know when your script finish the execution.

If you want to exit the process at some point in your script runs:

```javascript
process.exit(code) // 0 success 1 error
```

Or throw an unhandled `Error`

### Environment variables

Your script can use environment variables from the shell or a `.env` file.

// script.js
```javascript
console.log(process.env.NODE_ENV) // development
console.log(process.env.SOME_VARIABLE) // foo
```

```
$ NODE_ENV=development SOME_VARIABLE=foo browser-runner scripts.js
```

## Contributing

PRs accepted.

## License

GPL-3.0 © dxos

---
_Source: https://npm.io/package/@dxos/browser-runner · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
