Skip to content

Commit

Permalink
update docs and fix critical error in bundled js
Browse files Browse the repository at this point in the history
  • Loading branch information
heinthanth committed May 16, 2022
1 parent 39b2a8a commit 5b26f15
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.xuerun linguist-language=YAML
83 changes: 81 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,53 @@ And move it to ur path. Eg. `/usr/bin`, `/usr/local/bin`, etc. For windows, the

## Configurations

Complete Configurations Example:
General usage is:

```text
xuerun [tasks]... [options]...
```

TL;DR

```shell
$ xuerun # will execute 'all' task if exist
$ xuerun task-name-to-execute # will execute 'task-name-to-execute'
$ xuerun -t some-tasks-path # will look for task in 'some-tasks-path'
$ xuerun -n some-task # will print commands to run ( won't execute )
```

### Tasks Path ( `--tasks, -t` option )

Unless `--tasks ( -t )` is given, XueRun will look for `tasks.xuerun`. If `tasks.xuerun` exists, XueRun will use that.

```shell
$ xuerun someName # xuerun will look for someName in tasks.xuerun
$ xuerun -t example.xuerun someName # xuerun will look for someName in example.xuerun
```

### Task Name ( `[tasks]` )

Unless task names are given, XueRun will look for a task named `all`. If `all` task exists, XueRun will execute that.

```shell
$ xuerun task-name-to-execute
```

You can give multiple task name too.

```shell
$ xuerun taskOne taskTwo taskThree # these tasks will run in sequantial order.
```

### Recon ( `--recon, -n` option )

Use `--recon ( -n )` to emulate task execution ( but won't work in some edge cases ).

```shell
$ xuerun -n some-task # xuerun will print commands instead of executing
```

### Complete Configurations Example

```yaml
dependOnMeToo:
Expand All @@ -20,7 +66,7 @@ dependOnMeToo:
when: opt.release # if opt.release is true
- cmd: echo "Since passParentOptions is true in 'dependOnMe' task"
when: opt.release # if opt.release is true
passEnv: [ PATH ] # u need to pass env to use ur PATH.
passEnv: [ PATH ] # u need to pass env to use ur PATH. Pass true to pass all environment variables
dependOnMe:
description: some task
# cwd: / # try change cwd and see {{ Deno.cwd() }} output!
Expand Down Expand Up @@ -48,6 +94,38 @@ taskName:
I think this example show u a lot! Have Fun xuerunning!
## Some Notes
Here's some notes to be considered.
### Option passing
If u specified `passEnv` and `passCLI`, given env and CLI arguments will be passed to `opt` object and can be used with `{{}}`



### When Option ( WARNING )

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.

```yaml
- cmd: echo "Don't run me unless status is 'true'"
when: opt.status == 'true'
```

### JS Expression

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.

```yaml
command:
- cmd: echo "it's PATH env => {{ opt.PATH }} and CLI release option => {{ opt.release }}"
passEnv: [ PATH ]
passCLI: true
```

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`.

## How to Build

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

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

2 changes: 1 addition & 1 deletion example.xuerun
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependOnMeToo:
when: opt.release # if opt.release is true
- cmd: echo "Since passParentOptions is true in 'dependOnMe' task"
when: opt.release # if opt.release is true
passEnv: [ PATH ] # u need to pass env to use ur PATH.
passEnv: [ PATH ] # u need to pass env to use ur PATH. Pass true to pass all environment variables
dependOnMe:
description: some task
# cwd: / # try change cwd and see {{ Deno.cwd() }} output!
Expand Down
7 changes: 5 additions & 2 deletions src/core.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ export runRecipe = (rc, recipe, options, recon, asIngredient) ->
Deno.exit(1)

# used by eval
opt = currentOption
globalThis.opt = currentOption
# don't run if eval when is false
if typeof cmdOption == "object" and not Boolean(eval(cmdOption.when)) then continue
if typeof cmdOption == "object" and not Boolean(eval(cmdOption.when))
continue
# I don't need here
delete globalThis.opt

commandToRun = [
(if typeof cmdOption == "object" and
Expand Down

0 comments on commit 5b26f15

Please sign in to comment.