From 39b2a8aa44dd7accd965fd7e24bb7ffcd3e410ec Mon Sep 17 00:00:00 2001 From: Hein Thant Maung Maung Date: Sun, 15 May 2022 22:29:57 +0630 Subject: [PATCH] add example, fix wrong validation --- README.md | 43 ++++++++++++++++++++++++++++++++++++++++++- example.xuerun | 32 ++++++++++++++++++++++++++++++++ src/schema.coffee | 8 ++++++-- 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 example.xuerun diff --git a/README.md b/README.md index d52f17d..fc697ae 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,48 @@ Just a make-like task runner but with more power! It's written in CoffeeScript + ## Downloads Go to Release page and download builds! -And move it to your path. Eg. `/usr/bin`, `/usr/local/bin`, etc. For windows, the same :P. +And move it to ur path. Eg. `/usr/bin`, `/usr/local/bin`, etc. For windows, the same :P. + +## Configurations + +Complete Configurations Example: + +```yaml +dependOnMeToo: + description: another task + # cwd: /some/path/too + command: + - cmd: echo "I can read {{ opt.release }} if 'dependOnMe' task call me" + 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. +dependOnMe: + description: some task + # cwd: / # try change cwd and see {{ Deno.cwd() }} output! + shell: bash # default shell + dependencies: + - name: dependOnMeToo + passParentOptions: true + command: + - cmd: echo "I can read {{ opt.FOO }}" + shell: zsh # u can use another shell rather than default one + - cmd: echo "Don't run me unless status is 'true'" + when: opt.status == 'true' + - echo "I'm a command too. In {{ Deno.cwd() }}" # deno expressions are supported +taskName: + description: a description + dependencies: + - name: dependOnMe + options: + FOO: bar + status: "{{ opt.status == 1 }}" + release: "{{ opt.release }}" # u can use --release CLI option if passCLI is true + passCLI: true + command: echo "this is main task" +``` + +I think this example show u a lot! Have Fun xuerunning! ## How to Build diff --git a/example.xuerun b/example.xuerun new file mode 100644 index 0000000..ea3e641 --- /dev/null +++ b/example.xuerun @@ -0,0 +1,32 @@ +dependOnMeToo: + description: another task + # cwd: /some/path/too + command: + - cmd: echo "I can read {{ opt.release }} if 'dependOnMe' task call me" + 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. +dependOnMe: + description: some task + # cwd: / # try change cwd and see {{ Deno.cwd() }} output! + shell: bash # default shell + dependencies: + - name: dependOnMeToo + passParentOptions: true + command: + - cmd: echo "I can read {{ opt.FOO }}" + shell: zsh # u can use another shell rather than default one + - cmd: echo "Don't run me unless status is 'true'" + when: opt.status == 'true' + - echo "I'm a command too. In {{ Deno.cwd() }}" # deno expressions are supported +taskName: + description: a description + dependencies: + - name: dependOnMe + options: + FOO: bar + status: "{{ opt.status == 1 }}" + release: "{{ opt.release }}" # u can use --release CLI option if passCLI is true + passCLI: true + command: echo "this is main task" \ No newline at end of file diff --git a/src/schema.coffee b/src/schema.coffee index 6dcd42d..33f58ac 100644 --- a/src/schema.coffee +++ b/src/schema.coffee @@ -2,8 +2,12 @@ import { create, defaulted, optional, union, object, record, array, string, number, boolean, validate } from "https://esm.sh/superstruct"; # use eval? -XueRunUserCmd = union([string(), object({ shell: optional(string()), cmd: string(), - 'when': defaulted(union([string(), number(), boolean()]), () => 'true') })]); +XueRunUserCmd = union([ + string(), + object({ + shell: optional(string()), + cmd: string(), + 'when': defaulted(optional(union([string(), number(), boolean()])), () => 'true') }) ]); XueRunIngredient$option = union([string(), number(), boolean()]) export XueRunIngredient = object