Skip to content

Commit 5b26f15

Browse files
committed
update docs and fix critical error in bundled js
1 parent 39b2a8a commit 5b26f15

File tree

4 files changed

+88
-5
lines changed

4 files changed

+88
-5
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.xuerun linguist-language=YAML

README.md

+81-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,53 @@ And move it to ur path. Eg. `/usr/bin`, `/usr/local/bin`, etc. For windows, the
99

1010
## Configurations
1111

12-
Complete Configurations Example:
12+
General usage is:
13+
14+
```text
15+
xuerun [tasks]... [options]...
16+
```
17+
18+
TL;DR
19+
20+
```shell
21+
$ xuerun # will execute 'all' task if exist
22+
$ xuerun task-name-to-execute # will execute 'task-name-to-execute'
23+
$ xuerun -t some-tasks-path # will look for task in 'some-tasks-path'
24+
$ xuerun -n some-task # will print commands to run ( won't execute )
25+
```
26+
27+
### Tasks Path ( `--tasks, -t` option )
28+
29+
Unless `--tasks ( -t )` is given, XueRun will look for `tasks.xuerun`. If `tasks.xuerun` exists, XueRun will use that.
30+
31+
```shell
32+
$ xuerun someName # xuerun will look for someName in tasks.xuerun
33+
$ xuerun -t example.xuerun someName # xuerun will look for someName in example.xuerun
34+
```
35+
36+
### Task Name ( `[tasks]` )
37+
38+
Unless task names are given, XueRun will look for a task named `all`. If `all` task exists, XueRun will execute that.
39+
40+
```shell
41+
$ xuerun task-name-to-execute
42+
```
43+
44+
You can give multiple task name too.
45+
46+
```shell
47+
$ xuerun taskOne taskTwo taskThree # these tasks will run in sequantial order.
48+
```
49+
50+
### Recon ( `--recon, -n` option )
51+
52+
Use `--recon ( -n )` to emulate task execution ( but won't work in some edge cases ).
53+
54+
```shell
55+
$ xuerun -n some-task # xuerun will print commands instead of executing
56+
```
57+
58+
### Complete Configurations Example
1359

1460
```yaml
1561
dependOnMeToo:
@@ -20,7 +66,7 @@ dependOnMeToo:
2066
when: opt.release # if opt.release is true
2167
- cmd: echo "Since passParentOptions is true in 'dependOnMe' task"
2268
when: opt.release # if opt.release is true
23-
passEnv: [ PATH ] # u need to pass env to use ur PATH.
69+
passEnv: [ PATH ] # u need to pass env to use ur PATH. Pass true to pass all environment variables
2470
dependOnMe:
2571
description: some task
2672
# cwd: / # try change cwd and see {{ Deno.cwd() }} output!
@@ -48,6 +94,38 @@ taskName:
4894
4995
I think this example show u a lot! Have Fun xuerunning!
5096
97+
## Some Notes
98+
99+
Here's some notes to be considered.
100+
101+
### Option passing
102+
103+
If u specified `passEnv` and `passCLI`, given env and CLI arguments will be passed to `opt` object and can be used with `{{}}`
104+
105+
106+
107+
### When Option ( WARNING )
108+
109+
This `taskName > command > subcommand > when` ( when ) expression is evaluated using `eval` function from javascript and can inject raw JS codes. So, use at ur own risk.
110+
111+
```yaml
112+
- cmd: echo "Don't run me unless status is 'true'"
113+
when: opt.status == 'true'
114+
```
115+
116+
### JS Expression
117+
118+
You can use `{{ expression }}` in commands, options, etc. XueRun use `eta` to render those. string templates. Keep in mind, raw JS code can be injected too. So, use at ur own risk.
119+
120+
```yaml
121+
command:
122+
- cmd: echo "it's PATH env => {{ opt.PATH }} and CLI release option => {{ opt.release }}"
123+
passEnv: [ PATH ]
124+
passCLI: true
125+
```
126+
127+
Then, when u run with `xuerun taskName --release`, `opt.PATH` will be replaced with ur PATH env and `opt.release` will be replaced with `true`.
128+
51129
## How to Build
52130

53131
First, clone this repo. Then, run "tools/bootstrap.ts"
@@ -59,3 +137,4 @@ deno run tools/bootstrap.ts
59137
## License
60138

61139
XueRun is licensed under BSD-2-Clause. For more, see [LICENSE](LICENSE).
140+

example.xuerun

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependOnMeToo:
66
when: opt.release # if opt.release is true
77
- cmd: echo "Since passParentOptions is true in 'dependOnMe' task"
88
when: opt.release # if opt.release is true
9-
passEnv: [ PATH ] # u need to pass env to use ur PATH.
9+
passEnv: [ PATH ] # u need to pass env to use ur PATH. Pass true to pass all environment variables
1010
dependOnMe:
1111
description: some task
1212
# cwd: / # try change cwd and see {{ Deno.cwd() }} output!

src/core.coffee

+5-2
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ export runRecipe = (rc, recipe, options, recon, asIngredient) ->
7676
Deno.exit(1)
7777

7878
# used by eval
79-
opt = currentOption
79+
globalThis.opt = currentOption
8080
# don't run if eval when is false
81-
if typeof cmdOption == "object" and not Boolean(eval(cmdOption.when)) then continue
81+
if typeof cmdOption == "object" and not Boolean(eval(cmdOption.when))
82+
continue
83+
# I don't need here
84+
delete globalThis.opt
8285

8386
commandToRun = [
8487
(if typeof cmdOption == "object" and

0 commit comments

Comments
 (0)