Skip to content

Commit 83eed22

Browse files
authored
Merge pull request #20 from andywer/release/0.10
Merge v0.10 alpha into master
2 parents 145823d + daafc96 commit 83eed22

File tree

13 files changed

+1255
-3889
lines changed

13 files changed

+1255
-3889
lines changed

README.md

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# 🤖 puppet-run
22

3-
Run anything JavaScript in a headless Chrome from your command line 🔥
3+
Run anything JavaScript in Chrome with puppeteer and pipe it's output back to your terminal 🔥
44

5-
Transparently bundles your input files using the [Parcel bundler](https://parceljs.org). Why? Because [Karma](https://karma-runner.github.io) sucks.
5+
Transparently bundles your input files and runs them in a headless Chromium browser. Great for running tests in an actual browser!
6+
7+
How does it relate to [Karma](https://karma-runner.github.io)? It's everything that Karma is not: It's small, it's fast and trivial to set up.
68

79
🚀&nbsp;&nbsp;Runs any script in a headless Chrome<br />
810
📦&nbsp;&nbsp;Zero-config transparent bundling<br />
911
⚙️&nbsp;&nbsp;Uses existing Babel, TypeScript, ... config if present<br />
10-
💡&nbsp;&nbsp;Supports TypeScript, JSX, Vue out of the box<br />
12+
💡&nbsp;&nbsp;Supports TypeScript, ES modules &amp; JSX out of the box<br />
1113
🖥&nbsp;&nbsp;Pipes console output and errors to host shell<br />
1214

1315

@@ -29,19 +31,24 @@ npx puppet-run [<arguments>]
2931

3032
## Usage
3133

34+
### Basics
35+
3236
```sh
3337
npx puppet-run ./path/to/script.js [arguments and options here will be passed to the script]
3438
```
3539

36-
The script can basically be any JavaScript or TypeScript file. It will be bundled transparently using the [parcel bundler](https://parceljs.org). It usually works out-of-the-box with zero configuration. If you need to configure the build process, read up on how to configure `parcel`.
40+
The script can be any JavaScript or TypeScript file. It will be transparently transpiled via Babel using `@babel/preset-env`, `@babel/preset-react` & `@babel/preset-typescript` and bundled using `browserify`. It usually works out-of-the-box with zero configuration.
3741

38-
To run Mocha tests:
42+
You just need to call `puppet.exit()` or optionally `puppet.exit(statusCode: number)` when the script is done, so `puppet-run` knows that the script is finished. The `puppet` object is a global, injected by `puppet-run`.
43+
44+
### Run mocha tests
3945

4046
```sh
41-
npx puppet-run plugin:mocha [...mocha options] ./path/to/*.test.js
47+
npm install puppet-run-plugin-mocha
48+
npx puppet-run --plugin=mocha [...mocha options] ./path/to/*.test.js
4249
```
4350

44-
Print some help on how to use the tool:
51+
### Print help texts
4552

4653
```sh
4754
npx puppet-run --help
@@ -50,71 +57,54 @@ npx puppet-run --help
5057
Print help text how to use this plugin:
5158

5259
```sh
53-
npx puppet-run plugin:mocha --help
60+
npx puppet-run --plugin=mocha --help
5461
```
5562

5663

5764
## Example
5865

59-
Let's see how a simple script looks like:
66+
This is how a simple script might look like:
6067

6168
```js
62-
// cowsays.js
63-
import * as cowsay from "cowsay"
69+
import { detect } from "detect-browser"
70+
71+
const browser = detect()
6472

6573
// You can use window.*, since this will be run in Chrome
6674
const text = window.atob("SSBydW4gaW4gYSBicm93c2Vy")
6775

6876
// Everything logged here will be piped to your host terminal
69-
console.log(cowsay.say({ text }))
77+
console.log(text)
78+
console.log(`I am being run in a ${browser.name} ${browser.version}`)
7079

7180
// Explicitly terminate the script when you are done
7281
puppet.exit()
7382
```
7483

75-
Recognize the final `puppet.exit()`? You have to explicitly tell puppet-run when the script is done doing its thing.
84+
Recognize the final `puppet.exit()`? You need to tell `puppet-run` when the script has finished.
7685

7786
Have a look at the section "Scripting API" below to learn more about that globally available `puppet` object.
7887

79-
Let's have some fun and see our sample script run in all its glory!
88+
Let's run the sample script!
8089

8190
```sh
82-
npx puppet-run ./cowsays.js
91+
npm install detect-browser puppet-run
92+
npx puppet-run ./sample.js
8393
```
8494

8595
```
86-
_________________________
87-
< I live in a browser now >
88-
-------------------------
89-
\ ^__^
90-
\ (oo)\_______
91-
(__)\ )\/\
92-
||----w |
93-
|| ||
96+
I live in a browser now
97+
I am being run in a chrome 75.0
9498
```
9599

96100
Have fun!
97101

98102

99103
## Plugins
100104

101-
Plugins make it easy to integrate your script with testing frameworks or other external functionality. Check out the [plugins repository](https://github.com/andywer/puppet-run-plugins).
102-
103-
Here is how to use the mocha plugin:
104-
105-
```sh
106-
npm install puppet-run-plugin-mocha
107-
npx puppet-run plugin:mocha ./*.test.js [--reporter "spec"]
108-
```
109-
110-
This way you can just pass an arbitrary usual mocha test file without having to care about `puppet.exit()` or any boilerplate code.
111-
112-
You can also get help how to use a plugin:
113-
114-
```sh
115-
npx puppet-run plugin:mocha --help
116-
```
105+
Plugins make it easy to integrate your script with testing frameworks or other extra functionality.
117106

107+
Check out the 👉 [plugins repository](https://github.com/andywer/puppet-run-plugins).
118108

119109
## Scripting API
120110

0 commit comments

Comments
 (0)