mirror of
https://github.com/go-task/task.git
synced 2026-06-25 13:46:13 +00:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb96a39b46 | ||
|
|
a540634b5b | ||
|
|
e15576bc47 | ||
|
|
95359760ae | ||
|
|
be209cb7b6 | ||
|
|
9f125502f8 | ||
|
|
3f856c4b1c | ||
|
|
f55fb1e3a5 | ||
|
|
b7112e02db | ||
|
|
b136166fc9 | ||
|
|
75727c3d68 | ||
|
|
6c625b3359 | ||
|
|
60759a4e3b | ||
|
|
582a66bb2f | ||
|
|
d78f78bb5c | ||
|
|
71b7d062d5 | ||
|
|
c6138a0660 | ||
|
|
ce4ac97269 | ||
|
|
2088a86512 | ||
|
|
e296fe2b98 | ||
|
|
96b8890ecc | ||
|
|
db6fae2f5b | ||
|
|
6743cdbb65 | ||
|
|
71466c9a27 | ||
|
|
1bdf7e3192 | ||
|
|
7285f3c844 | ||
|
|
eb257d3aa7 | ||
|
|
87f11491d9 | ||
|
|
5735a02473 | ||
|
|
47dd9b5a03 | ||
|
|
7652d7889b |
1
.github/FUNDING.yml
vendored
1
.github/FUNDING.yml
vendored
@@ -1,2 +1,3 @@
|
|||||||
open_collective: task
|
open_collective: task
|
||||||
patreon: andreynering
|
patreon: andreynering
|
||||||
|
custom: 'https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=GSVDU63RKG45A¤cy_code=BRL&source=url'
|
||||||
|
|||||||
6
.github/ISSUE_TEMPLATE.md
vendored
6
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,6 +0,0 @@
|
|||||||
<!--
|
|
||||||
If relevant, include the following information:
|
|
||||||
- Task version
|
|
||||||
- OS
|
|
||||||
- Example Taskfile showing the issue
|
|
||||||
-->
|
|
||||||
14
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
14
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
name: Bug Report
|
||||||
|
about: Use the template to report bugs and issues
|
||||||
|
labels: bug
|
||||||
|
---
|
||||||
|
|
||||||
|
- Task version:
|
||||||
|
- Operating System:
|
||||||
|
|
||||||
|
### Example Taskfile showing the issue
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
|
||||||
|
```
|
||||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: Questions, Ideas and General Discussions
|
||||||
|
url: https://github.com/go-task/task/discussions
|
||||||
|
about: Ask questions and discuss general ideas with the community
|
||||||
12
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
12
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
name: Feature Request
|
||||||
|
about: Use the template to make feature requests
|
||||||
|
labels: feature
|
||||||
|
---
|
||||||
|
|
||||||
|
Describe in detail what feature do you want to see in Task.
|
||||||
|
Give examples if possible.
|
||||||
|
|
||||||
|
Please, search if this wasn't proposed before, and if this is more like an idea
|
||||||
|
than a strong feature request, consider opening a
|
||||||
|
[discussion](https://github.com/go-task/task/discussions) instead.
|
||||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v1
|
||||||
with:
|
with:
|
||||||
go-version: 1.14.x
|
go-version: 1.15.x
|
||||||
|
|
||||||
- name: Run GoReleaser
|
- name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v1
|
uses: goreleaser/goreleaser-action@v1
|
||||||
|
|||||||
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -5,7 +5,7 @@ jobs:
|
|||||||
name: Test
|
name: Test
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: [1.13.x, 1.14.x]
|
go-version: [1.14.x, 1.15.x]
|
||||||
platform: [ubuntu-latest, macos-latest, windows-latest]
|
platform: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
runs-on: ${{matrix.platform}}
|
runs-on: ${{matrix.platform}}
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v3.0.1
|
||||||
|
|
||||||
|
- Do not error if a specified dotenv file does not exist
|
||||||
|
([#378](https://github.com/go-task/task/issues/378), [#385](https://github.com/go-task/task/pull/385)).
|
||||||
|
- Fix panic when you have empty tasks in your Taskfile
|
||||||
|
([#338](https://github.com/go-task/task/issues/338), [#362](https://github.com/go-task/task/pull/362)).
|
||||||
|
|
||||||
## v3.0.0
|
## v3.0.0
|
||||||
|
|
||||||
- On `v3`, all CLI variables will be considered global variables
|
- On `v3`, all CLI variables will be considered global variables
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -1,23 +1,10 @@
|
|||||||

|

|
||||||

|

|
||||||
|

|
||||||
|
|
||||||
# Task
|
# Task
|
||||||
|
|
||||||
Task is a task runner / build tool that aims to be simpler and easier to use
|
Task is a task runner / build tool that aims to be simpler and easier to use
|
||||||
than, for example, [GNU Make](https://www.gnu.org/software/make/).
|
than, for example, [GNU Make](https://www.gnu.org/software/make/).
|
||||||
|
|
||||||
See [taskfile.dev](https://taskfile.dev) for documentation.
|
See [taskfile.dev](https://taskfile.dev) for the documentation.
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Sponsors
|
|
||||||
|
|
||||||
[](https://opencollective.com/task)
|
|
||||||
|
|
||||||
## Backers
|
|
||||||
|
|
||||||
[](https://opencollective.com/task)
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
[](https://github.com/go-task/task/graphs/contributors)
|
|
||||||
|
|||||||
18
Taskfile.yml
18
Taskfile.yml
@@ -24,8 +24,14 @@ tasks:
|
|||||||
env:
|
env:
|
||||||
CGO_ENABLED: '0'
|
CGO_ENABLED: '0'
|
||||||
|
|
||||||
dl-deps:
|
mod:
|
||||||
desc: Downloads cli dependencies
|
desc: Downloads and tidy Go modules
|
||||||
|
cmds:
|
||||||
|
- go mod download
|
||||||
|
- go mod tidy
|
||||||
|
|
||||||
|
cli-deps:
|
||||||
|
desc: Downloads CLI dependencies
|
||||||
cmds:
|
cmds:
|
||||||
- task: go-get
|
- task: go-get
|
||||||
vars: {REPO: golang.org/x/lint/golint}
|
vars: {REPO: golang.org/x/lint/golint}
|
||||||
@@ -34,12 +40,6 @@ tasks:
|
|||||||
- task: go-get
|
- task: go-get
|
||||||
vars: {REPO: github.com/goreleaser/godownloader}
|
vars: {REPO: github.com/goreleaser/godownloader}
|
||||||
|
|
||||||
update-deps:
|
|
||||||
desc: Updates dependencies
|
|
||||||
cmds:
|
|
||||||
- dep ensure
|
|
||||||
- dep ensure -update
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
desc: Cleans temp files and folders
|
desc: Cleans temp files and folders
|
||||||
cmds:
|
cmds:
|
||||||
@@ -62,7 +62,7 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- goreleaser --snapshot --rm-dist
|
- goreleaser --snapshot --rm-dist
|
||||||
|
|
||||||
generate-install-script:
|
gen-install-script:
|
||||||
desc: Generate install script using https://github.com/goreleaser/godownloader
|
desc: Generate install script using https://github.com/goreleaser/godownloader
|
||||||
cmds:
|
cmds:
|
||||||
- godownloader --repo go-task/task -o install-task.sh
|
- godownloader --repo go-task/task -o install-task.sh
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package args
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ParseV3 parses command line argument: tasks and global variables
|
// ParseV3 parses command line argument: tasks and global variables
|
||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/go-task/task/v3/internal/args"
|
"github.com/go-task/task/v3/args"
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@@ -10,9 +10,9 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/go-task/task/v3"
|
"github.com/go-task/task/v3"
|
||||||
"github.com/go-task/task/v3/internal/args"
|
"github.com/go-task/task/v3/args"
|
||||||
"github.com/go-task/task/v3/internal/logger"
|
"github.com/go-task/task/v3/internal/logger"
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|||||||
24
completion/fish/task.fish
Normal file
24
completion/fish/task.fish
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
function __task_get_tasks --description "Prints all available tasks with their description"
|
||||||
|
task -l | sed '1d' | awk '{ $1=""; print $0 }' | tr ': ', '\t' | string trim
|
||||||
|
end
|
||||||
|
|
||||||
|
complete -c task -d 'Runs the specified task(s). Falls back to the "default" task if no task name was specified, or lists all tasks if an unknown task name was
|
||||||
|
specified.' -xa "(__task_get_tasks)"
|
||||||
|
|
||||||
|
|
||||||
|
complete -c task -s c -l color -d 'colored output (default true)'
|
||||||
|
complete -c task -s d -l dir -d 'sets directory of execution'
|
||||||
|
complete -c task -l dry -d 'compiles and prints tasks in the order that they would be run, without executing them'
|
||||||
|
complete -c task -s f -l force -d 'forces execution even when the task is up-to-date'
|
||||||
|
complete -c task -s h -l help -d 'shows Task usage'
|
||||||
|
complete -c task -s i -l init -d 'creates a new Taskfile.yml in the current folder'
|
||||||
|
complete -c task -s l -l list -d 'lists tasks with description of current Taskfile'
|
||||||
|
complete -c task -s o -l output -d 'sets output style: [interleaved|group|prefixed]' -xa "interleaved group prefixed"
|
||||||
|
complete -c task -s p -l parallel -d 'executes tasks provided on command line in parallel'
|
||||||
|
complete -c task -s s -l silent -d 'disables echoing'
|
||||||
|
complete -c task -l status -d 'exits with non-zero exit code if any of the given tasks is not up-to-date'
|
||||||
|
complete -c task -l summary -d 'show summary about a task'
|
||||||
|
complete -c task -s t -l taskfile -d 'choose which Taskfile to run. Defaults to "Taskfile.yml"'
|
||||||
|
complete -c task -s v -l verbose -d 'enables verbose mode'
|
||||||
|
complete -c task -l version -d 'show Task version'
|
||||||
|
complete -c task -s w -l watch -d 'enables watch of the given task'
|
||||||
@@ -38,18 +38,6 @@ guide to check the full schema documentation and Task features.
|
|||||||
if a given set of files haven't changed since last run (based either on its
|
if a given set of files haven't changed since last run (based either on its
|
||||||
timestamp or content).
|
timestamp or content).
|
||||||
|
|
||||||
## Sponsors
|
|
||||||
|
|
||||||
[](https://opencollective.com/task)
|
|
||||||
|
|
||||||
## Backers
|
|
||||||
|
|
||||||
[](https://opencollective.com/task)
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
[](https://github.com/go-task/task/graphs/contributors)
|
|
||||||
|
|
||||||
[make]: https://www.gnu.org/software/make/
|
[make]: https://www.gnu.org/software/make/
|
||||||
[go]: https://golang.org/
|
[go]: https://golang.org/
|
||||||
[yaml]: http://yaml.org/
|
[yaml]: http://yaml.org/
|
||||||
|
|||||||
@@ -4,5 +4,5 @@
|
|||||||
- [Taskfile Versions](taskfile_versions.md)
|
- [Taskfile Versions](taskfile_versions.md)
|
||||||
- [Examples](examples.md)
|
- [Examples](examples.md)
|
||||||
- [Releasing Task](releasing_task.md)
|
- [Releasing Task](releasing_task.md)
|
||||||
- [Alternative Task Runners](alternative_task_runners.md)
|
- [Donate](donate.md)
|
||||||
- [GitHub](https://github.com/go-task/task)
|
- [GitHub](https://github.com/go-task/task)
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
# Alternative task runners
|
|
||||||
|
|
||||||
## YAML based
|
|
||||||
|
|
||||||
- [rliebz/tusk][tusk]
|
|
||||||
|
|
||||||
## Go based
|
|
||||||
|
|
||||||
- [magefile/mage][mage]
|
|
||||||
|
|
||||||
## Make similar
|
|
||||||
|
|
||||||
- [casey/just][just]
|
|
||||||
|
|
||||||
[tusk]: https://github.com/rliebz/tusk
|
|
||||||
[mage]: https://github.com/magefile/mage
|
|
||||||
[just]: https://github.com/casey/just
|
|
||||||
35
docs/donate.md
Normal file
35
docs/donate.md
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Donate
|
||||||
|
|
||||||
|
If you find this project useful, you can consider donating by using one of the
|
||||||
|
channels listed below.
|
||||||
|
|
||||||
|
This is just a way of saying "thank you", it won't give you any benefits like
|
||||||
|
higher priority on issues or something similar.
|
||||||
|
|
||||||
|
## Open Collective
|
||||||
|
|
||||||
|
Task is on [Open Collective](https://opencollective.com/task) and you have
|
||||||
|
these options to donate:
|
||||||
|
|
||||||
|
- [$2 per month](https://opencollective.com/task/contribute/backer-4034/checkout)
|
||||||
|
- [$5 per month](https://opencollective.com/task/contribute/supporter-8404/checkout)
|
||||||
|
- [$20 per month](https://opencollective.com/task/contribute/sponsor-4035/checkout)
|
||||||
|
- [Custom value - One-time donation option supported](https://opencollective.com/task/donate)
|
||||||
|
|
||||||
|
## Patreon
|
||||||
|
|
||||||
|
I'm also on [Patreon](https://www.patreon.com/andreynering) if
|
||||||
|
you prefer:
|
||||||
|
|
||||||
|
- [$5 per month](https://www.patreon.com/join/andreynering/checkout?rid=4229277)
|
||||||
|
- [$10 per month](https://www.patreon.com/join/andreynering/checkout?rid=4229276)
|
||||||
|
- [$15 per month](https://www.patreon.com/join/andreynering/checkout?rid=4229275)
|
||||||
|
|
||||||
|
You can choose a custom value on any of the links above.
|
||||||
|
|
||||||
|
Patreon does not support one-time donation. As a workaround you can fire a
|
||||||
|
subscription and cancel it once the donation was succeded.
|
||||||
|
|
||||||
|
## PayPal
|
||||||
|
|
||||||
|
- [Any value - One-time donation](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=GSVDU63RKG45A¤cy_code=BRL&source=url)
|
||||||
@@ -73,7 +73,13 @@ scenarios like CIs. Many thanks to [GoDownloader][godownloader] for allowing
|
|||||||
easily generating this script.
|
easily generating this script.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -sL https://taskfile.dev/install.sh | sh
|
# For Default Installion to ./bin with debug logging
|
||||||
|
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d
|
||||||
|
|
||||||
|
# For Installation To /usr/local/bin for userwide access with debug logging
|
||||||
|
# May require sudo sh
|
||||||
|
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> This method will download the binary on the local `./bin` directory by default.
|
> This method will download the binary on the local `./bin` directory by default.
|
||||||
@@ -101,10 +107,13 @@ This installation method is community owned.
|
|||||||
|
|
||||||
First, make sure you have [Go][go] properly installed and setup.
|
First, make sure you have [Go][go] properly installed and setup.
|
||||||
|
|
||||||
Task requires [Go Modules](https://github.com/golang/go/wiki/Modules) and
|
You can easily install it globally by running:
|
||||||
doesn't officially support installing via `go get` anymore.
|
|
||||||
|
|
||||||
Installing in another directory:
|
```bash
|
||||||
|
go get -u github.com/go-task/task/v3/cmd/task
|
||||||
|
```
|
||||||
|
|
||||||
|
Or you can install into another directory:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/go-task/task
|
git clone https://github.com/go-task/task
|
||||||
|
|||||||
120
docs/usage.md
120
docs/usage.md
@@ -92,48 +92,8 @@ tasks:
|
|||||||
- echo "Using $KEYNAME"
|
- echo "Using $KEYNAME"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Operating System specific tasks
|
|
||||||
|
|
||||||
If you add a `Taskfile_{{GOOS}}.yml` you can override or amend your Taskfile
|
|
||||||
based on the operating system.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
Taskfile.yml:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
version: '3'
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
build:
|
|
||||||
cmds:
|
|
||||||
- echo "default"
|
|
||||||
```
|
|
||||||
|
|
||||||
Taskfile_linux.yml:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
version: '3'
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
build:
|
|
||||||
cmds:
|
|
||||||
- echo "linux"
|
|
||||||
```
|
|
||||||
|
|
||||||
Will print out `linux` and not `default`.
|
|
||||||
|
|
||||||
Keep in mind that the version of the files should match. Also, when redefining
|
|
||||||
a task the whole task is replaced, properties of the task are not merged.
|
|
||||||
|
|
||||||
It's also possible to have an OS specific `Taskvars.yml` file, like
|
|
||||||
`Taskvars_windows.yml`, `Taskvars_linux.yml`, or `Taskvars_darwin.yml`. See the
|
|
||||||
[variables section](#variables) below.
|
|
||||||
|
|
||||||
## Including other Taskfiles
|
## Including other Taskfiles
|
||||||
|
|
||||||
> This feature is still experimental and may have bugs.
|
|
||||||
|
|
||||||
If you want to share tasks between different projects (Taskfiles), you can use
|
If you want to share tasks between different projects (Taskfiles), you can use
|
||||||
the importing mechanism to include other Taskfiles using the `includes` keyword:
|
the importing mechanism to include other Taskfiles using the `includes` keyword:
|
||||||
|
|
||||||
@@ -150,6 +110,21 @@ namespace. So, you'd call `task docs:serve` to run the `serve` task from
|
|||||||
`documentation/Taskfile.yml` or `task docker:build` to run the `build` task
|
`documentation/Taskfile.yml` or `task docker:build` to run the `build` task
|
||||||
from the `DockerTasks.yml` file.
|
from the `DockerTasks.yml` file.
|
||||||
|
|
||||||
|
### OS-specific Taskfiles
|
||||||
|
|
||||||
|
With `version: '2'`, task automatically includes any `Taskfile_{{OS}}.yml`
|
||||||
|
if it exists (for example: `Taskfile_windows.yml`, `Taskfile_linux.yml` or
|
||||||
|
`Taskfile_darwin.yml`). Since this behavior was a bit too implicit, it
|
||||||
|
was removed on version 3, but you still can have a similar behavior by
|
||||||
|
explicitly importing these files:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
includes:
|
||||||
|
build: ./Taskfile_{{OS}}.yml
|
||||||
|
```
|
||||||
|
|
||||||
### Directory of included Taskfile
|
### Directory of included Taskfile
|
||||||
|
|
||||||
By default, included Taskfile's tasks are ran in the current directory, even
|
By default, included Taskfile's tasks are ran in the current directory, even
|
||||||
@@ -345,8 +320,8 @@ tasks:
|
|||||||
- public/style.css
|
- public/style.css
|
||||||
```
|
```
|
||||||
|
|
||||||
`sources` and `generates` can be files or file patterns. When both are given,
|
`sources` and `generates` can be files or file patterns. When given,
|
||||||
Task will compare the checksum of the files to determine if it's
|
Task will compare the checksum of the source files to determine if it's
|
||||||
necessary to run the task. If not, it will just print a message like
|
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`.
|
||||||
You will probably want to ignore the `.task` folder in your `.gitignore` file
|
You will probably want to ignore the `.task` folder in your `.gitignore` file
|
||||||
@@ -371,6 +346,10 @@ tasks:
|
|||||||
|
|
||||||
> TIP: method `none` skips any validation and always run the task.
|
> TIP: method `none` skips any validation and always run the task.
|
||||||
|
|
||||||
|
> NOTE: for the `checksum` (default) method to work, it's only necessary to
|
||||||
|
> inform the source files, but if you want to use the `timestamp` method, you
|
||||||
|
> also need to inform the generated files with `generates`.
|
||||||
|
|
||||||
### Using programmatic checks to indicate a task is up to date.
|
### Using programmatic checks to indicate a task 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
|
||||||
@@ -451,18 +430,19 @@ with any other tasks that depend on it.
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
task_will_fail:
|
task-will-fail:
|
||||||
preconditions:
|
preconditions:
|
||||||
- sh: "exit 1"
|
- sh: "exit 1"
|
||||||
|
|
||||||
task_will_also_fail:
|
task-will-also-fail:
|
||||||
deps:
|
deps:
|
||||||
- task_will_fail
|
- task-will-fail
|
||||||
|
|
||||||
task_will_still_fail:
|
task-will-still-fail:
|
||||||
cmds:
|
cmds:
|
||||||
- task: task_will_fail
|
- task: task-will-fail
|
||||||
- echo "I will not run"
|
- echo "I will not run"
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -472,10 +452,9 @@ When doing interpolation of variables, Task will look for the below.
|
|||||||
They are listed below in order of importance (e.g. most important first):
|
They are listed below in order of importance (e.g. most important first):
|
||||||
|
|
||||||
- Variables declared in the task definition
|
- Variables declared in the task definition
|
||||||
- Variables given while calling a task from another.
|
- Variables given while calling a task from another
|
||||||
(See [Calling another task](#calling-another-task) above)
|
(See [Calling another task](#calling-another-task) above)
|
||||||
- Variables declared in the `vars:` option in the `Taskfile`
|
- Global variables (those declared in the `vars:` option in the Taskfile)
|
||||||
- Variables available in the `Taskvars.yml` file
|
|
||||||
- Environment variables
|
- Environment variables
|
||||||
|
|
||||||
Example of sending parameters with environment variables:
|
Example of sending parameters with environment variables:
|
||||||
@@ -484,11 +463,12 @@ Example of sending parameters with environment variables:
|
|||||||
$ TASK_VARIABLE=a-value task do-something
|
$ TASK_VARIABLE=a-value task do-something
|
||||||
```
|
```
|
||||||
|
|
||||||
> TIP: A special variable `.TASK` is always available containg the task name.
|
> TIP: A special variable `.TASK` is always available containing the task name.
|
||||||
|
|
||||||
Since some shells don't support above syntax to set environment variables
|
Since some shells don't support above syntax to set environment variables
|
||||||
(Windows) tasks also accepts a similar style when not in the beginning of
|
(Windows) tasks also accepts a similar style when not in the beginning of
|
||||||
the command.
|
the command.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ task write-file FILE=file.txt "CONTENT=Hello, World!" print "MESSAGE=All done!"
|
$ task write-file FILE=file.txt "CONTENT=Hello, World!" print "MESSAGE=All done!"
|
||||||
```
|
```
|
||||||
@@ -520,38 +500,6 @@ tasks:
|
|||||||
- echo "{{.GREETING}}"
|
- echo "{{.GREETING}}"
|
||||||
```
|
```
|
||||||
|
|
||||||
Example of `Taskvars.yml` file:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
PROJECT_NAME: My Project
|
|
||||||
DEV_MODE: production
|
|
||||||
GIT_COMMIT: {sh: git log -n 1 --format=%h}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Variables expansion
|
|
||||||
|
|
||||||
Variables are expanded 2 times by default. You can change that by setting the
|
|
||||||
`expansions:` option. Change that will be necessary if you compose many
|
|
||||||
variables together:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
version: '3'
|
|
||||||
|
|
||||||
expansions: 3
|
|
||||||
|
|
||||||
vars:
|
|
||||||
FOO: foo
|
|
||||||
BAR: bar
|
|
||||||
BAZ: baz
|
|
||||||
FOOBAR: "{{.FOO}}{{.BAR}}"
|
|
||||||
FOOBARBAZ: "{{.FOOBAR}}{{.BAZ}}"
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
default:
|
|
||||||
cmds:
|
|
||||||
- echo "{{.FOOBARBAZ}}"
|
|
||||||
```
|
|
||||||
|
|
||||||
### Dynamic variables
|
### Dynamic variables
|
||||||
|
|
||||||
The below syntax (`sh:` prop in a variable) is considered a dynamic variable.
|
The below syntax (`sh:` prop in a variable) is considered a dynamic variable.
|
||||||
@@ -712,7 +660,7 @@ Please note: *showing the summary will not execute the command*.
|
|||||||
## Overriding task name
|
## Overriding task name
|
||||||
|
|
||||||
Sometimes you may want to override the task name print on summary, up-to-date
|
Sometimes you may want to override the task name print on summary, up-to-date
|
||||||
messates to STDOUT, etc. In this case you can just set `label:`, which can also
|
messages to STDOUT, etc. In this case you can just set `label:`, which can also
|
||||||
be interpolated with variables:
|
be interpolated with variables:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -932,9 +880,9 @@ tasks:
|
|||||||
|
|
||||||
## Watch tasks
|
## Watch tasks
|
||||||
|
|
||||||
If you give a `--watch` or `-w` argument, task will watch for file changes
|
With the flags `--watch` or `-w` task will watch for file 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 knows which files to watch.
|
||||||
|
|
||||||
[gotemplate]: https://golang.org/pkg/text/template/
|
[gotemplate]: https://golang.org/pkg/text/template/
|
||||||
[minify]: https://github.com/tdewolff/minify/tree/master/cmd/minify
|
[minify]: https://github.com/tdewolff/minify/tree/master/cmd/minify
|
||||||
|
|||||||
4
go.mod
4
go.mod
@@ -9,9 +9,9 @@ require (
|
|||||||
github.com/radovskyb/watcher v1.0.5
|
github.com/radovskyb/watcher v1.0.5
|
||||||
github.com/spf13/pflag v1.0.3
|
github.com/spf13/pflag v1.0.3
|
||||||
github.com/stretchr/testify v1.5.1
|
github.com/stretchr/testify v1.5.1
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
|
||||||
mvdan.cc/sh/v3 v3.1.2
|
mvdan.cc/sh/v3 v3.2.1
|
||||||
)
|
)
|
||||||
|
|
||||||
go 1.13
|
go 1.13
|
||||||
|
|||||||
30
go.sum
30
go.sum
@@ -1,5 +1,5 @@
|
|||||||
github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=
|
github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
@@ -15,25 +15,23 @@ github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
|||||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
|
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
|
||||||
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
|
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
|
||||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||||
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
|
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
|
||||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
github.com/mattn/go-zglob v0.0.1 h1:xsEx/XUoVlI6yXjqBK062zYhRTZltCNmYPx6v+8DNaY=
|
github.com/mattn/go-zglob v0.0.1 h1:xsEx/XUoVlI6yXjqBK062zYhRTZltCNmYPx6v+8DNaY=
|
||||||
github.com/mattn/go-zglob v0.0.1/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
|
github.com/mattn/go-zglob v0.0.1/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
|
||||||
github.com/pkg/diff v0.0.0-20190930165518-531926345625/go.mod h1:kFj35MyHn14a6pIgWhm46KVjJr5CHys3eEYxkuKD1EI=
|
github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/radovskyb/watcher v1.0.5 h1:wqt7gb+HjGacvFoLTKeT44C+XVPxu7bvHvKT1IvZ7rw=
|
github.com/radovskyb/watcher v1.0.5 h1:wqt7gb+HjGacvFoLTKeT44C+XVPxu7bvHvKT1IvZ7rw=
|
||||||
github.com/radovskyb/watcher v1.0.5/go.mod h1:78okwvY5wPdzcb1UYnip1pvrZNIVEIh/Cm+ZuvsUYIg=
|
github.com/radovskyb/watcher v1.0.5/go.mod h1:78okwvY5wPdzcb1UYnip1pvrZNIVEIh/Cm+ZuvsUYIg=
|
||||||
github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||||
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
|
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
|
||||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
@@ -42,27 +40,23 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy
|
|||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200217220822-9197077df867 h1:JoRuNIf+rpHl+VhScRQQvzbHed86tKkqwPMV34T8myw=
|
golang.org/x/sys v0.0.0-20201029080932-201ba4db2418 h1:HlFl4V6pEMziuLXyRkm5BIYq1y1GAbb02pRlWvI54OM=
|
||||||
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201029080932-201ba4db2418/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407 h1:5zh5atpUEdIc478E/ebrIaHLKcfVvG6dL/fGv7BcMoM=
|
golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407 h1:5zh5atpUEdIc478E/ebrIaHLKcfVvG6dL/fGv7BcMoM=
|
||||||
golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
mvdan.cc/editorconfig v0.1.1-0.20200121172147-e40951bde157/go.mod h1:Ge4atmRUYqueGppvJ7JNrtqpqokoJEFxYbP0Z+WeKS8=
|
mvdan.cc/editorconfig v0.1.1-0.20200121172147-e40951bde157/go.mod h1:Ge4atmRUYqueGppvJ7JNrtqpqokoJEFxYbP0Z+WeKS8=
|
||||||
mvdan.cc/sh/v3 v3.1.2 h1:PG5BYlwtrkZTbJXUy25r0/q9shB5ObttCaknkOIB1XQ=
|
mvdan.cc/sh/v3 v3.2.1 h1:uQBpiGM+rEuHse3Q+W7ajuJUeOtFVJUN/6GeX4/dUWE=
|
||||||
mvdan.cc/sh/v3 v3.1.2/go.mod h1:F+Vm4ZxPJxDKExMLhvjuI50oPnedVXpfjNSrusiTOno=
|
mvdan.cc/sh/v3 v3.2.1/go.mod h1:fPQmabBpREM/XQ9YXSU5ZFZ/Sm+PmKP9/vkFHgYKJEI=
|
||||||
|
|||||||
2
help.go
2
help.go
@@ -6,7 +6,7 @@ import (
|
|||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/go-task/task/v3/internal/logger"
|
"github.com/go-task/task/v3/internal/logger"
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PrintTasksHelp prints help os tasks that have a description
|
// PrintTasksHelp prints help os tasks that have a description
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package compiler
|
package compiler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Compiler handles compilation of a task before its execution.
|
// Compiler handles compilation of a task before its execution.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetEnviron the all return all environment variables encapsulated on a
|
// GetEnviron the all return all environment variables encapsulated on a
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import (
|
|||||||
"github.com/go-task/task/v3/internal/compiler"
|
"github.com/go-task/task/v3/internal/compiler"
|
||||||
"github.com/go-task/task/v3/internal/execext"
|
"github.com/go-task/task/v3/internal/execext"
|
||||||
"github.com/go-task/task/v3/internal/logger"
|
"github.com/go-task/task/v3/internal/logger"
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
|
||||||
"github.com/go-task/task/v3/internal/templater"
|
"github.com/go-task/task/v3/internal/templater"
|
||||||
|
"github.com/go-task/task/v3/taskfile"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ compiler.Compiler = &CompilerV2{}
|
var _ compiler.Compiler = &CompilerV2{}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import (
|
|||||||
"github.com/go-task/task/v3/internal/compiler"
|
"github.com/go-task/task/v3/internal/compiler"
|
||||||
"github.com/go-task/task/v3/internal/execext"
|
"github.com/go-task/task/v3/internal/execext"
|
||||||
"github.com/go-task/task/v3/internal/logger"
|
"github.com/go-task/task/v3/internal/logger"
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
|
||||||
"github.com/go-task/task/v3/internal/templater"
|
"github.com/go-task/task/v3/internal/templater"
|
||||||
|
"github.com/go-task/task/v3/taskfile"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ compiler.Compiler = &CompilerV3{}
|
var _ compiler.Compiler = &CompilerV3{}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/go-task/task/v3/internal/logger"
|
"github.com/go-task/task/v3/internal/logger"
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PrintTasks(l *logger.Logger, t *taskfile.Taskfile, c []taskfile.Call) {
|
func PrintTasks(l *logger.Logger, t *taskfile.Taskfile, c []taskfile.Call) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/go-task/task/v3/internal/logger"
|
"github.com/go-task/task/v3/internal/logger"
|
||||||
"github.com/go-task/task/v3/internal/summary"
|
"github.com/go-task/task/v3/internal/summary"
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Templater is a help struct that allow us to call "replaceX" funcs multiple
|
// Templater is a help struct that allow us to call "replaceX" funcs multiple
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/go-task/task/v3/internal/execext"
|
"github.com/go-task/task/v3/internal/execext"
|
||||||
"github.com/go-task/task/v3/internal/logger"
|
"github.com/go-task/task/v3/internal/logger"
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/go-task/task/v3/internal/execext"
|
"github.com/go-task/task/v3/internal/execext"
|
||||||
"github.com/go-task/task/v3/internal/logger"
|
"github.com/go-task/task/v3/internal/logger"
|
||||||
"github.com/go-task/task/v3/internal/status"
|
"github.com/go-task/task/v3/internal/status"
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Status returns an error if any the of given tasks is not up-to-date
|
// Status returns an error if any the of given tasks is not up-to-date
|
||||||
|
|||||||
4
task.go
4
task.go
@@ -16,8 +16,8 @@ import (
|
|||||||
"github.com/go-task/task/v3/internal/logger"
|
"github.com/go-task/task/v3/internal/logger"
|
||||||
"github.com/go-task/task/v3/internal/output"
|
"github.com/go-task/task/v3/internal/output"
|
||||||
"github.com/go-task/task/v3/internal/summary"
|
"github.com/go-task/task/v3/internal/summary"
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
"github.com/go-task/task/v3/internal/taskfile/read"
|
"github.com/go-task/task/v3/taskfile/read"
|
||||||
|
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|||||||
47
task_test.go
47
task_test.go
@@ -12,7 +12,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/go-task/task/v3"
|
"github.com/go-task/task/v3"
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@@ -56,6 +56,16 @@ func (fct fileContentTest) Run(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEmptyTask(t *testing.T) {
|
||||||
|
e := &task.Executor{
|
||||||
|
Dir: "testdata/empty_task",
|
||||||
|
Stdout: ioutil.Discard,
|
||||||
|
Stderr: ioutil.Discard,
|
||||||
|
}
|
||||||
|
assert.NoError(t, e.Setup(), "e.Setup()")
|
||||||
|
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "default"}))
|
||||||
|
}
|
||||||
|
|
||||||
func TestEnv(t *testing.T) {
|
func TestEnv(t *testing.T) {
|
||||||
tt := fileContentTest{
|
tt := fileContentTest{
|
||||||
Dir: "testdata/env",
|
Dir: "testdata/env",
|
||||||
@@ -819,7 +829,7 @@ func TestShortTaskNotation(t *testing.T) {
|
|||||||
|
|
||||||
func TestDotenvShouldIncludeAllEnvFiles(t *testing.T) {
|
func TestDotenvShouldIncludeAllEnvFiles(t *testing.T) {
|
||||||
tt := fileContentTest{
|
tt := fileContentTest{
|
||||||
Dir: "testdata/dotenv",
|
Dir: "testdata/dotenv/default",
|
||||||
Target: "default",
|
Target: "default",
|
||||||
TrimSpace: false,
|
TrimSpace: false,
|
||||||
Files: map[string]string{
|
Files: map[string]string{
|
||||||
@@ -829,26 +839,9 @@ func TestDotenvShouldIncludeAllEnvFiles(t *testing.T) {
|
|||||||
tt.Run(t)
|
tt.Run(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDotenvShouldErrorWithIncludeEnvPath(t *testing.T) {
|
|
||||||
const dir = "testdata/dotenv"
|
|
||||||
const entry = "Taskfile-errors1.yml"
|
|
||||||
|
|
||||||
var buff bytes.Buffer
|
|
||||||
e := task.Executor{
|
|
||||||
Dir: dir,
|
|
||||||
Entrypoint: entry,
|
|
||||||
Summary: true,
|
|
||||||
Stdout: &buff,
|
|
||||||
Stderr: &buff,
|
|
||||||
}
|
|
||||||
err := e.Setup()
|
|
||||||
assert.Error(t, err)
|
|
||||||
assert.Contains(t, err.Error(), "no such file")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDotenvShouldErrorWhenIncludingDependantDotenvs(t *testing.T) {
|
func TestDotenvShouldErrorWhenIncludingDependantDotenvs(t *testing.T) {
|
||||||
const dir = "testdata/dotenv"
|
const dir = "testdata/dotenv/error_included_envs"
|
||||||
const entry = "Taskfile-errors2.yml"
|
const entry = "Taskfile.yml"
|
||||||
|
|
||||||
var buff bytes.Buffer
|
var buff bytes.Buffer
|
||||||
e := task.Executor{
|
e := task.Executor{
|
||||||
@@ -863,3 +856,15 @@ func TestDotenvShouldErrorWhenIncludingDependantDotenvs(t *testing.T) {
|
|||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Contains(t, err.Error(), "move the dotenv")
|
assert.Contains(t, err.Error(), "move the dotenv")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDotenvShouldAllowMissingEnv(t *testing.T) {
|
||||||
|
tt := fileContentTest{
|
||||||
|
Dir: "testdata/dotenv/missing_env",
|
||||||
|
Target: "default",
|
||||||
|
TrimSpace: false,
|
||||||
|
Files: map[string]string{
|
||||||
|
"include.txt": "INCLUDE1='' INCLUDE2=''\n",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
tt.Run(t)
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package taskfile_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
|
||||||
"github.com/go-task/task/v3/internal/templater"
|
"github.com/go-task/task/v3/internal/templater"
|
||||||
|
"github.com/go-task/task/v3/taskfile"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
@@ -37,11 +37,15 @@ func Taskfile(dir string, entrypoint string) (*taskfile.Taskfile, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if v >= 3.0 && len(t.Dotenv) > 0 {
|
if v >= 3.0 {
|
||||||
for _, dotEnvPath := range t.Dotenv {
|
for _, dotEnvPath := range t.Dotenv {
|
||||||
if !filepath.IsAbs(dotEnvPath) {
|
if !filepath.IsAbs(dotEnvPath) {
|
||||||
dotEnvPath = filepath.Join(dir, dotEnvPath)
|
dotEnvPath = filepath.Join(dir, dotEnvPath)
|
||||||
}
|
}
|
||||||
|
if _, err := os.Stat(dotEnvPath); os.IsNotExist(err) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
envs, err := godotenv.Read(dotEnvPath)
|
envs, err := godotenv.Read(dotEnvPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -119,6 +123,10 @@ func Taskfile(dir string, entrypoint string) (*taskfile.Taskfile, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for name, task := range t.Tasks {
|
for name, task := range t.Tasks {
|
||||||
|
if task == nil {
|
||||||
|
task = &taskfile.Task{}
|
||||||
|
t.Tasks[name] = task
|
||||||
|
}
|
||||||
task.Task = name
|
task.Task = name
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
@@ -31,7 +31,7 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
Env *Vars
|
Env *Vars
|
||||||
Tasks Tasks
|
Tasks Tasks
|
||||||
Silent bool
|
Silent bool
|
||||||
Dotenv []string
|
Dotenv []string
|
||||||
}
|
}
|
||||||
if err := unmarshal(&taskfile); err != nil {
|
if err := unmarshal(&taskfile); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -3,7 +3,7 @@ package taskfile_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
dotenv: ['include1/.env', 'include1/envs/.env', 'file-does-not-exist']
|
dotenv: ['../include1/.env', '../include1/envs/.env']
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
default:
|
default:
|
||||||
cmds:
|
cmds:
|
||||||
- echo "INCLUDE1='$INCLUDE1' INCLUDE2='$INCLUDE2'" > include-errors1.txt
|
- echo "INCLUDE1='$INCLUDE1' INCLUDE2='$INCLUDE2'" > include.txt
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
includes:
|
includes:
|
||||||
include1: './include1'
|
include1: '../include1'
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
default:
|
default:
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
dotenv: ['include1/.env', 'include1/envs/.env']
|
dotenv: ['.env']
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
default:
|
default:
|
||||||
4
testdata/empty_task/Taskfile.yml
vendored
Normal file
4
testdata/empty_task/Taskfile.yml
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
default:
|
||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
|
|
||||||
"github.com/go-task/task/v3/internal/execext"
|
"github.com/go-task/task/v3/internal/execext"
|
||||||
"github.com/go-task/task/v3/internal/status"
|
"github.com/go-task/task/v3/internal/status"
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
|
||||||
"github.com/go-task/task/v3/internal/templater"
|
"github.com/go-task/task/v3/internal/templater"
|
||||||
|
"github.com/go-task/task/v3/taskfile"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CompiledTask returns a copy of a task, but replacing variables in almost all
|
// CompiledTask returns a copy of a task, but replacing variables in almost all
|
||||||
|
|||||||
2
watch.go
2
watch.go
@@ -9,7 +9,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-task/task/v3/internal/logger"
|
"github.com/go-task/task/v3/internal/logger"
|
||||||
"github.com/go-task/task/v3/internal/taskfile"
|
"github.com/go-task/task/v3/taskfile"
|
||||||
"github.com/mattn/go-zglob"
|
"github.com/mattn/go-zglob"
|
||||||
"github.com/radovskyb/watcher"
|
"github.com/radovskyb/watcher"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user