Skip to content

Commit 0deb2d7

Browse files
committed
improve README documentation
1 parent fdd7e7f commit 0deb2d7

File tree

1 file changed

+39
-37
lines changed

1 file changed

+39
-37
lines changed

README.md

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ css:
148148
- npm run buildcss
149149
```
150150

151+
If there are more than one dependency, they always run in parallel for better
152+
performance.
153+
151154
Each task can only be run once. If it is included from another dependend task causing
152155
a cyclomatic dependency, execution will be stopped.
153156

@@ -268,55 +271,52 @@ up-to-date.
268271

269272
### Variables
270273

271-
```yml
272-
build:
273-
deps: [setvar]
274-
cmds:
275-
- echo "{{.PREFIX}} {{.THEVAR}}"
276-
vars:
277-
PREFIX: "Path:"
274+
When doing interpolation of variables, Task will look for the below.
275+
They are listed below in order of importance (e.g. most important first):
278276

279-
setvar:
280-
cmds:
281-
- echo "{{.PATH}}"
282-
set: THEVAR
283-
```
277+
- Variables given while calling a task from another.
278+
(See [Calling another task](#calling-another-task) above)
279+
- Environment variables
280+
- Variables available in the `Taskvars.yml` file
281+
- Variables declared locally in the task
284282

285-
The above sample saves the path into a new variable which is then again echoed.
283+
Example of overriding with environment variables:
286284

287-
You can use environment variables, task level variables and a file called
288-
`Taskvars.yml` as source of variables.
285+
```bash
286+
$ TASK_VARIABLE=a-value task do-something
287+
```
289288

290-
They are evaluated in the following order:
289+
Example of `Taskvars.yml` file:
290+
291+
```yml
292+
PROJECT_NAME: My Project
293+
DEV_MODE: production
294+
GIT_COMMIT: $git log -n 1 --format=%h
295+
```
291296

292-
Task local variables are overwritten by variables found in `Taskvars` file.
293-
Variables found in `Taskvars` file are overwritten with variables from the
294-
environment. The output of the last command is stored in the environment. So
295-
you can do something like this:
297+
Example of locally declared vars:
296298

297299
```yml
298-
build:
299-
deps: [setvar]
300+
print-var:
300301
cmds:
301-
- echo "{{.PREFIX}} '{{.THEVAR}}'"
302+
echo "{{.VAR}}"
302303
vars:
303-
PREFIX: "Result: "
304-
305-
setvar:
306-
cmds:
307-
- echo -n "a"
308-
- echo -n "{{.THEVAR}}b"
309-
- echo -n "{{.THEVAR}}c"
310-
set: THEVAR
304+
VAR: Hello!
311305
```
312306

313-
The result of a run of build would be:
307+
> NOTE: It's also possible setting a variable globally using `set` attribute
308+
in task, but this is deprecated:
314309

315-
```
316-
a
317-
ab
318-
abc
319-
Result: 'abc'
310+
```yml
311+
build:
312+
deps: [set-message]
313+
cmds:
314+
- echo "Message: {{.MESSAGE}}"
315+
316+
set-message:
317+
cmds:
318+
- echo "This is an important message"
319+
set: MESSAGE
320320
```
321321

322322
#### Dynamic variables
@@ -333,6 +333,8 @@ build:
333333
LAST_GIT_COMMIT: $git log -n 1 --format=%h
334334
```
335335

336+
This works for all types of variables.
337+
336338
### Go's template engine
337339

338340
Task parse commands as [Go's template engine][gotemplate] before executing

0 commit comments

Comments
 (0)