1
0
mirror of https://github.com/go-task/task.git synced 2025-07-17 01:43:07 +02:00

update README

This commit is contained in:
Andrey Nering
2017-08-05 14:52:32 -03:00
parent e67792177d
commit 300376b0b1

View File

@ -38,7 +38,9 @@ The `task_checksums.txt` file contains the SHA-256 checksum for each file.
## Usage ## Usage
Create a file called `Taskfile.yml` in the root of the project. Create a file called `Taskfile.yml` in the root of the project.
The `cmds` attribute should contains the commands of a task: The `cmds` attribute should contains the commands of a task.
The example below allows compile a Go app and uses [Minify][minify] to concat
and minify multiple CSS files into a single one.
```yml ```yml
build: build:
@ -47,7 +49,7 @@ build:
assets: assets:
cmds: cmds:
- gulp - minify -o public/style.css src/css
``` ```
Running the tasks is as simple as running: Running the tasks is as simple as running:
@ -101,7 +103,7 @@ build:
Will print out `linux` and not default. Will print out `linux` and not default.
It's also possible to have OS specific `Taskvars.yml` file, like It's also possible to have OS specific `Taskvars.yml` file, like
`Taskvars_windows.yml` or `Taskvars_darwin.yml`. See the `Taskvars_windows.yml`, `Taskfile_linux.yml` or `Taskvars_darwin.yml`. See the
[variables section](#variables) below. [variables section](#variables) below.
### Task directory ### Task directory
@ -111,10 +113,11 @@ located. But you can easily make the task run in another folder informing
`dir`: `dir`:
```yml ```yml
js: serve:
dir: www/public/js dir: public/www
cmds: cmds:
- gulp # run http server
- caddy
``` ```
### Task dependencies ### Task dependencies
@ -130,7 +133,7 @@ build:
assets: assets:
cmds: cmds:
- gulp - minify -o public/style.css src/css
``` ```
In the above example, `assets` will always run right before `build` if you run In the above example, `assets` will always run right before `build` if you run
@ -144,29 +147,16 @@ assets:
js: js:
cmds: cmds:
- npm run buildjs - minify -o public/script.js src/js
css: css:
cmds: cmds:
- npm run buildcss - minify -o public/style.css src/css
``` ```
If there are more than one dependency, they always run in parallel for better If there are more than one dependency, they always run in parallel for better
performance. performance.
Each task can only be run once. If it is included from another dependend task causing
a cyclomatic dependency, execution will be stopped.
```yml
task1:
deps: [task2]
task2:
deps: [task1]
```
The above will fail with the message: "cyclic dependency detected".
### Calling another task ### Calling another task
When a task has many dependencies, they are executed concurrently. This will When a task has many dependencies, they are executed concurrently. This will
@ -233,24 +223,24 @@ build:
js: js:
cmds: cmds:
- npm run buildjs - minify -o public/script.js src/js
sources: sources:
- js/src/**/*.js - src/js/**/*.js
generates: generates:
- public/bundle.js - public/script.js
css: css:
cmds: cmds:
- npm run buildcss - minify -o public/style.css src/css
sources: sources:
- css/src/*.css - src/css/**/*.css
generates: generates:
- public/bundle.css - public/style.css
``` ```
`sources` and `generates` should be file patterns. When both are given, Task `sources` and `generates` can be files or file patterns. When both are given,
will compare the modification date/time of the files to determine if it's Task will compare the modification date/time of the files to determine if it's
necessary to run the task. If not, it will just print necessary to run the task. If not, it will just print a message like
`Task "js" is up to date`. `Task "js" is up to date`.
Alternatively, you can inform a sequence of tests as `status`. If no error Alternatively, you can inform a sequence of tests as `status`. If no error
@ -408,11 +398,11 @@ test:
js: js:
cmds: cmds:
- npm run buildjs - minify -o public/script.js src/js
css: css:
cmds: cmds:
- npm run buildcss - minify -o public/style.css src/css
``` ```
would print the following output: would print the following output:
@ -482,6 +472,10 @@ If you give a `--watch` or `-w` argument, task will watch for files changes
and run the task again. This requires the `sources` attribute to be given, and run the task again. This requires the `sources` attribute to be given,
so task know which files to watch. so task know which files to watch.
## Task in the wild
- [How I Build My Static Assets for Hugo][post-hugo]
## Alternative task runners ## Alternative task runners
- YAML based: - YAML based:
@ -502,3 +496,5 @@ so task know which files to watch.
[godo]: https://github.com/go-godo/godo [godo]: https://github.com/go-godo/godo
[grift]: https://github.com/markbates/grift [grift]: https://github.com/markbates/grift
[sh]: https://github.com/mvdan/sh [sh]: https://github.com/mvdan/sh
[post-hugo]: https://blog.carlmjohnson.net/post/2017/hugo-asset-pipeline/
[minify]: https://github.com/tdewolff/minify/tree/master/cmd/minify