Skip to content

Commit 4fe0a88

Browse files
committed
Update readme
1 parent f778d07 commit 4fe0a88

File tree

1 file changed

+23
-35
lines changed

1 file changed

+23
-35
lines changed

README.md

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ How does it relate to [Karma](https://karma-runner.github.io)? It's everything t
99
🚀&nbsp;&nbsp;Runs any script in a headless Chrome<br />
1010
📦&nbsp;&nbsp;Zero-config transparent bundling<br />
1111
⚙️&nbsp;&nbsp;Uses existing Babel, TypeScript, ... config if present<br />
12-
💡&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 />
1313
🖥&nbsp;&nbsp;Pipes console output and errors to host shell<br />
1414

1515

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

3232
## Usage
3333

34+
### Basics
35+
3436
```sh
3537
npx puppet-run ./path/to/script.js [arguments and options here will be passed to the script]
3638
```
3739

38-
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.
41+
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`.
3943

40-
To run Mocha tests:
44+
### Run mocha tests
4145

4246
```sh
47+
npm install puppet-run-plugin-mocha
4348
npx puppet-run --plugin=mocha [...mocha options] ./path/to/*.test.js
4449
```
4550

46-
Print some help on how to use the tool:
51+
### Print help texts
4752

4853
```sh
4954
npx puppet-run --help
@@ -58,65 +63,48 @@ npx puppet-run --plugin=mocha --help
5863

5964
## Example
6065

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

6368
```js
64-
// cowsays.js
65-
import * as cowsay from "cowsay"
69+
import { detect } from "detect-browser"
70+
71+
const browser = detect()
6672

6773
// You can use window.*, since this will be run in Chrome
6874
const text = window.atob("SSBydW4gaW4gYSBicm93c2Vy")
6975

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

7380
// Explicitly terminate the script when you are done
7481
puppet.exit()
7582
```
7683

77-
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.
7885

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

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

8390
```sh
84-
npx puppet-run ./cowsays.js
91+
npm install detect-browser puppet-run
92+
npx puppet-run ./sample.js
8593
```
8694

8795
```
88-
_________________________
89-
< I live in a browser now >
90-
-------------------------
91-
\ ^__^
92-
\ (oo)\_______
93-
(__)\ )\/\
94-
||----w |
95-
|| ||
96+
I live in a browser now
97+
I am being run in a chrome 75.0
9698
```
9799

98100
Have fun!
99101

100102

101103
## Plugins
102104

103-
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).
104-
105-
Here is how to use the mocha plugin:
106-
107-
```sh
108-
npm install puppet-run-plugin-mocha
109-
npx puppet-run --plugin=mocha ./*.test.js [--reporter "spec"]
110-
```
111-
112-
This way you can just pass an arbitrary usual mocha test file without having to care about `puppet.exit()` or any boilerplate code.
113-
114-
You can also get help how to use a plugin:
115-
116-
```sh
117-
npx puppet-run --plugin=mocha --help
118-
```
105+
Plugins make it easy to integrate your script with testing frameworks or other extra functionality.
119106

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

121109
## Scripting API
122110

0 commit comments

Comments
 (0)