You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
⚙️ Uses existing Babel, TypeScript, ... config if present<br />
10
-
💡 Supports TypeScript, JSX, Vue out of the box<br />
12
+
💡 Supports TypeScript, ES modules & JSX out of the box<br />
11
13
🖥 Pipes console output and errors to host shell<br />
12
14
13
15
@@ -29,19 +31,24 @@ npx puppet-run [<arguments>]
29
31
30
32
## Usage
31
33
34
+
### Basics
35
+
32
36
```sh
33
37
npx puppet-run ./path/to/script.js [arguments and options here will be passed to the script]
34
38
```
35
39
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.
37
41
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`.
// You can use window.*, since this will be run in Chrome
66
74
consttext=window.atob("SSBydW4gaW4gYSBicm93c2Vy")
67
75
68
76
// 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}`)
70
79
71
80
// Explicitly terminate the script when you are done
72
81
puppet.exit()
73
82
```
74
83
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.
76
85
77
86
Have a look at the section "Scripting API" below to learn more about that globally available `puppet` object.
78
87
79
-
Let's have some fun and see our sample script run in all its glory!
88
+
Let's run the sample script!
80
89
81
90
```sh
82
-
npx puppet-run ./cowsays.js
91
+
npm install detect-browser puppet-run
92
+
npx puppet-run ./sample.js
83
93
```
84
94
85
95
```
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
94
98
```
95
99
96
100
Have fun!
97
101
98
102
99
103
## Plugins
100
104
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).
0 commit comments