diff --git a/CHANGELOG.md b/CHANGELOG.md index 55da79aef6..7b32b0470f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Unreleased +## v3.41.0 - 2025-01-18 - Fixed an issue where dynamic variables were not properly logged in verbose mode (#1920, #1921 by @mgbowman). diff --git a/package-lock.json b/package-lock.json index b0fe77bcce..1624fdf211 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@go-task/cli", - "version": "3.40.1", + "version": "3.41.0", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 9e4a9e746e..da5877535a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@go-task/cli", - "version": "3.40.1", + "version": "3.41.0", "description": "A task runner / simpler Make alternative written in Go", "scripts": { "postinstall": "go-npm install", diff --git a/website/docs/changelog.mdx b/website/docs/changelog.mdx index 236c34206c..ff72992fa2 100644 --- a/website/docs/changelog.mdx +++ b/website/docs/changelog.mdx @@ -5,17 +5,40 @@ sidebar_position: 14 # Changelog -## Unreleased +## v3.41.0 - 2025-01-18 -- Document deferred tasks in the schema reference and fix an error in the JSON - schema for such tasks (#1907 by @mjpieters). +- Fixed an issue where dynamic variables were not properly logged in verbose + mode (#1920, #1921 by @mgbowman). +- Support `silent` for defer statements (#1877, #1879 by @danilobuerger). +- Added an option to exclude some tasks from being included (#1859 by + @vmaerten). +- Fixed an issue where a required variable was incorrectly handled in a template + function (#1950, #1962 by @vmaerten). +- Expose a new `TASK_DIR` special variable, which will contain the absolute path + of task directory. (#1959, #1961 by @vmaerten). +- Fixed fatal bugs that caused concurrent map writes (#1605, #1972, #1974 by + @pd93, @GrahamDennis and @trim21). +- Refactored internal ordered map implementation to use + [github.com/elliotchance/orderedmap](https://github.com/elliotchance/orderedmap) + (#1797 by @pd93). +- Fixed a bug where variables defined at the task level were being ignored in + the `requires` section. (#1960, #1955, #1768 by @vmaerten and @mokeko) +- The `CHECKSUM` and `TIMESTAMP` variables are now accessible within `cmds` + (#1872 by @niklasr22). +- Updated [installation docs](https://taskfile.dev/installation) and added pip + installation method (#935, #1989 by @pd93). +- Fixed a bug where dynamic variables could not access environment variables + (#630, #1869 by @rohm1 and @pd93). +- Disable version check for use as an external library (#1938 by @leaanthony). ## v3.40.1 - 2024-12-06 -- Fixed a security issue in `git-urls` by switching to the maintained fork `chainguard-dev/git-urls` (#1917 by - @AlekSi). -- Added missing `platforms` property to `cmds` that use `for` (#1915 by @dkarter). -- Added misspell linter to check for misspelled English words (#1883 by @christiandins). +- Fixed a security issue in `git-urls` by switching to the maintained fork + `chainguard-dev/git-urls` (#1917 by @AlekSi). +- Added missing `platforms` property to `cmds` that use `for` (#1915 by + @dkarter). +- Added misspell linter to check for misspelled English words (#1883 by + @christiandins). ## v3.40.0 - 2024-11-05 @@ -309,8 +332,8 @@ sidebar_position: 14 - Added the [Remote Taskfiles experiment](https://taskfile.dev/experiments/remote-taskfiles) as a draft (#1152, #1317 by @pd93). -- Improve performance of content checksumming on `sources:` by replacing md5 with - [XXH3](https://xxhash.com/) which is much faster. This is a soft breaking +- Improve performance of content checksumming on `sources:` by replacing md5 + with [XXH3](https://xxhash.com/) which is much faster. This is a soft breaking change because checksums will be invalidated when upgrading to this release (#1325 by @ReillyBrogan). @@ -457,8 +480,8 @@ it a go and let us know what you think via a - Fixed a bug where tasks were sometimes incorrectly marked as internal (#1007 by @pd93). - Update to Go 1.20 (bump minimum version to 1.19) (#1010 by @pd93) -- Added environment variable `FORCE_COLOR` support to force color output. - Useful for environments without TTY (#1003 by @automation-stack) +- Added environment variable `FORCE_COLOR` support to force color output. Useful + for environments without TTY (#1003 by @automation-stack) ## v3.20.0 - 2023-01-14 diff --git a/website/versioned_docs/version-latest/changelog.mdx b/website/versioned_docs/version-latest/changelog.mdx index 7f17d975d4..ff72992fa2 100644 --- a/website/versioned_docs/version-latest/changelog.mdx +++ b/website/versioned_docs/version-latest/changelog.mdx @@ -5,12 +5,40 @@ sidebar_position: 14 # Changelog +## v3.41.0 - 2025-01-18 + +- Fixed an issue where dynamic variables were not properly logged in verbose + mode (#1920, #1921 by @mgbowman). +- Support `silent` for defer statements (#1877, #1879 by @danilobuerger). +- Added an option to exclude some tasks from being included (#1859 by + @vmaerten). +- Fixed an issue where a required variable was incorrectly handled in a template + function (#1950, #1962 by @vmaerten). +- Expose a new `TASK_DIR` special variable, which will contain the absolute path + of task directory. (#1959, #1961 by @vmaerten). +- Fixed fatal bugs that caused concurrent map writes (#1605, #1972, #1974 by + @pd93, @GrahamDennis and @trim21). +- Refactored internal ordered map implementation to use + [github.com/elliotchance/orderedmap](https://github.com/elliotchance/orderedmap) + (#1797 by @pd93). +- Fixed a bug where variables defined at the task level were being ignored in + the `requires` section. (#1960, #1955, #1768 by @vmaerten and @mokeko) +- The `CHECKSUM` and `TIMESTAMP` variables are now accessible within `cmds` + (#1872 by @niklasr22). +- Updated [installation docs](https://taskfile.dev/installation) and added pip + installation method (#935, #1989 by @pd93). +- Fixed a bug where dynamic variables could not access environment variables + (#630, #1869 by @rohm1 and @pd93). +- Disable version check for use as an external library (#1938 by @leaanthony). + ## v3.40.1 - 2024-12-06 -- Fixed a security issue in `git-urls` by switching to the maintained fork `chainguard-dev/git-urls` (#1917 by - @AlekSi). -- Added missing `platforms` property to `cmds` that use `for` (#1915 by @dkarter). -- Added misspell linter to check for misspelled English words (#1883 by @christiandins). +- Fixed a security issue in `git-urls` by switching to the maintained fork + `chainguard-dev/git-urls` (#1917 by @AlekSi). +- Added missing `platforms` property to `cmds` that use `for` (#1915 by + @dkarter). +- Added misspell linter to check for misspelled English words (#1883 by + @christiandins). ## v3.40.0 - 2024-11-05 @@ -304,8 +332,8 @@ sidebar_position: 14 - Added the [Remote Taskfiles experiment](https://taskfile.dev/experiments/remote-taskfiles) as a draft (#1152, #1317 by @pd93). -- Improve performance of content checksumming on `sources:` by replacing md5 with - [XXH3](https://xxhash.com/) which is much faster. This is a soft breaking +- Improve performance of content checksumming on `sources:` by replacing md5 + with [XXH3](https://xxhash.com/) which is much faster. This is a soft breaking change because checksums will be invalidated when upgrading to this release (#1325 by @ReillyBrogan). @@ -452,8 +480,8 @@ it a go and let us know what you think via a - Fixed a bug where tasks were sometimes incorrectly marked as internal (#1007 by @pd93). - Update to Go 1.20 (bump minimum version to 1.19) (#1010 by @pd93) -- Added environment variable `FORCE_COLOR` support to force color output. - Useful for environments without TTY (#1003 by @automation-stack) +- Added environment variable `FORCE_COLOR` support to force color output. Useful + for environments without TTY (#1003 by @automation-stack) ## v3.20.0 - 2023-01-14 diff --git a/website/versioned_docs/version-latest/faq.mdx b/website/versioned_docs/version-latest/faq.mdx index 62b30f428d..bf8e764833 100644 --- a/website/versioned_docs/version-latest/faq.mdx +++ b/website/versioned_docs/version-latest/faq.mdx @@ -96,7 +96,7 @@ echo $a ## 'x' builtin command doesn't work on Windows -The default shell on Windows (`cmd` and `powershell`) does not have commands like +The default shell on Windows (`cmd` and `powershell`) do not have commands like `rm` and `cp` available as builtins. This means that these commands won't work. If you want to make your Taskfile fully cross-platform, you'll need to work around this limitation using one of the following methods: diff --git a/website/versioned_docs/version-latest/installation.mdx b/website/versioned_docs/version-latest/installation.mdx index 1e93bc8083..223f274c94 100644 --- a/website/versioned_docs/version-latest/installation.mdx +++ b/website/versioned_docs/version-latest/installation.mdx @@ -1,6 +1,7 @@ --- slug: /installation/ sidebar_position: 2 +toc_max_heading_level: 4 --- import Tabs from '@theme/Tabs'; @@ -10,154 +11,129 @@ import TabItem from '@theme/TabItem'; Task offers many installation methods. Check out the available methods below. +:::info + +Some of the methods below are marked as ![Community][community]. This means they +are not maintained by the Task team and may not be up-to-date. + +::: + ## Package Managers -### Homebrew +### [Homebrew][homebrew] ![][macos] ![][linux] \{#homebrew} -If you're on macOS or Linux and have [Homebrew][homebrew] installed, getting -Task is as simple as running: +Task is available via our official Homebrew tap [[source](https://github.com/go-task/homebrew-tap/blob/main/Formula/go-task.rb)]: ```shell brew install go-task/tap/go-task ``` -The above Formula is -[maintained by ourselves](https://github.com/go-task/homebrew-tap/blob/main/Formula/go-task.rb). - -Recently, Task was also made available -[on the official Homebrew repository](https://formulae.brew.sh/formula/go-task), -so you also have that option if you prefer: +Alternatively it can be installed from the official Homebrew +repository [[package](https://formulae.brew.sh/formula/go-task)] +[[source](https://github.com/Homebrew/homebrew-core/blob/master/Formula/g/go-task.rb)] by running: ```shell brew install go-task ``` -### pkgx +### [Snap][snapcraft] ![][macos] ![][linux] \{#snap} -If you're on macOS or Linux and have [pkgx][pkgx] installed, getting Task is as -simple as running: +Task is available on [Snapcraft][snapcraft] [[source](https://github.com/go-task/snap/blob/main/snap/snapcraft.yaml)], but keep in mind that your Linux +distribution should allow classic confinement for Snaps to Task work correctly: ```shell -pkgx task +sudo snap install task --classic ``` -or, if you have pkgx integration enabled: +### [npm][npm] ![][macos] ![][linux] ![][windows] \{#npm} + +Npm can be used as cross-platform way to install Task globally or as a +dependency of your project +[[package](https://www.npmjs.com/package/@go-task/cli)] [[source](https://github.com/go-task/task/blob/main/package.json)]: ```shell -task +npm install -g @go-task/cli ``` -This installation method is community owned. After a new release of Task, they -are automatically released by pkgx in a minimum of time. - -### Snap +### [pip][pip] ![][macos] ![][linux] ![][windows] ![][community] \{#pip} -Task is available in [Snapcraft][snapcraft], but keep in mind that your Linux -distribution should allow classic confinement for Snaps to Task work right: +Like npm, pip can be used as a cross-platform way to install Task +[[package](https://pypi.org/project/go-task-bin)] [[source](https://github.com/Bing-su/pip-binary-factory/tree/main/task)]: ```shell -sudo snap install task --classic +pip install go-task-bin ``` -### Chocolatey +### [WinGet][winget] ![][windows] \{#winget} -If you're on Windows and have [Chocolatey][choco] installed, getting Task is as -simple as running: +Task is available via the [community repository](https://github.com/microsoft/winget-pkgs) [[source](https://github.com/microsoft/winget-pkgs/tree/master/manifests/t/Task/Task)]: ```shell -choco install go-task +winget install Task.Task ``` -This installation method is community owned. - -### Scoop +### [Chocolatey][choco] ![][windows] ![][community] \{#chocolatey} -If you're on Windows and have [Scoop][scoop] installed, getting Task is as -simple as running: +[[package](https://community.chocolatey.org/packages/go-task)] [[source](https://github.com/Starz0r/ChocolateyPackagingScripts/blob/master/src/go-task_gh_build.py)] ```shell -scoop install task +choco install go-task ``` -This installation method is community owned. After a new release of Task, it may -take some time until it's available on Scoop. - -### AUR +### [Scoop][scoop] ![][windows] ![][community] \{#scoop} -If you're on Arch Linux you can install Task from -[AUR](https://aur.archlinux.org/packages/go-task-bin) using your favorite -package manager such as `yay`, `pacaur` or `yaourt`: +[[source](https://github.com/ScoopInstaller/Main/blob/master/bucket/task.json)] ```shell -yay -S go-task-bin +scoop install task ``` -Alternatively, there's -[this package](https://aur.archlinux.org/packages/go-task) which installs from -the source code instead of downloading the binary from the -[releases page](https://github.com/go-task/task/releases): +### Arch ([pacman][pacman]) ![][arch] ![][community] \{#arch} + +[[package](https://archlinux.org/packages/extra/x86_64/go-task/)] [[source](https://gitlab.archlinux.org/archlinux/packaging/packages/go-task)] ```shell -yay -S go-task +pacman -S go-task ``` -This installation method is community owned. +### Fedora ([dnf][dnf]) ![][fedora] ![][community] \{#fedora} -### Fedora - -If you're on Fedora Linux you can install Task from the official -[Fedora](https://packages.fedoraproject.org/pkgs/golang-github-task/go-task/) -repository using `dnf`: +[[package](https://packages.fedoraproject.org/pkgs/golang-github-task/go-task/)] [[source](https://src.fedoraproject.org/rpms/golang-github-task)] ```shell -sudo dnf install go-task +dnf install go-task ``` -This installation method is community owned. After a new release of Task, it may -take some time until it's available in -[Fedora](https://packages.fedoraproject.org/pkgs/golang-github-task/go-task/). - -### Nix +### NixOS ([nix][nix]) ![][nixos] ![][linux] ![][community] \{#nix} -If you're on NixOS or have Nix installed you can install Task from -[nixpkgs](https://github.com/NixOS/nixpkgs): +[[source](https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/go/go-task/package.nix)] ```shell nix-env -iA nixpkgs.go-task ``` -This installation method is community owned. After a new release of Task, it may -take some time until it's available in -[nixpkgs](https://github.com/NixOS/nixpkgs). +### [pacstall][pacstall] ![][debian] ![][ubuntu] ![][community] \{#pacstall} -### npm - -You can also use Node and npm to install Task by installing -[this package](https://www.npmjs.com/package/@go-task/cli). +[[package](https://pacstall.dev/packages/go-task-deb)] [[source](https://github.com/pacstall/pacstall-programs/blob/master/packages/go-task-deb/go-task-deb.pacscript)] ```shell -npm install -g @go-task/cli +pacstall -I go-task-deb ``` -### Winget +### [pkgx][pkgx] ![][macos] ![][linux] ![][community] \{#pkgx} -If you are using Windows and installed the -[winget](https://github.com/microsoft/winget-cli) package management tool, you -can install Task from [winget-pkgs](https://github.com/microsoft/winget-pkgs). +[[package](https://pkgx.dev/pkgs/taskfile.dev)] [[source](https://github.com/pkgxdev/pantry/blob/main/projects/taskfile.dev/package.yml)] ```shell -winget install Task.Task +pkgx task ``` -### Pacstall -If you are using Debian or Ubuntu, and have [Pacstall](https://pacstall.dev/) installed, you can install Task by running: +or, if you have pkgx integration enabled: ```shell -pacstall -I go-task-deb +task ``` -This installation method is community owned. After a new release of Task, it may take some time until it's available in [Pacstall](https://pacstall.dev/packages/go-task-deb). - ## Get The Binary ### Binary @@ -322,13 +298,33 @@ task --completion fish > ~/.config/fish/completions/task.fish {/* prettier-ignore-start */} -[go]: https://golang.org/ +[homebrew]: https://brew.sh [snapcraft]: https://snapcraft.io/task -[homebrew]: https://brew.sh/ -[installscript]: https://github.com/go-task/task/blob/main/install-task.sh -[releases]: https://github.com/go-task/task/releases +[winget]: https://github.com/microsoft/winget-cli +[choco]: https://chocolatey.org +[scoop]: https://scoop.sh +[pacman]: https://wiki.archlinux.org/title/Pacman +[dnf]: https://docs.fedoraproject.org/en-US/quick-docs/dnf +[nix]: https://nixos.org +[npm]: https://www.npmjs.com +[pip]: https://pip.pypa.io +[mise]: https://mise.jdx.dev +[aqua]: https://aquaproj.github.io +[pacstall]: https://github.com/pacstall/pacstall +[pkgx]: https://pkgx.sh + +[go]: https://golang.org [godownloader]: https://github.com/goreleaser/godownloader -[choco]: https://chocolatey.org/ -[scoop]: https://scoop.sh/ -[pkgx]: https://pkgx.sh/ +[releases]: https://github.com/go-task/task/releases +[installscript]: https://github.com/go-task/task/blob/main/install-task.sh + +[community]: https://img.shields.io/badge/Community%20Owned-orange +[windows]: https://custom-icon-badges.demolab.com/badge/Windows-0078D6?logo=windows11&logoColor=white +[macos]: https://img.shields.io/badge/MacOS-000000?logo=apple&logoColor=F0F0F0 +[linux]: https://img.shields.io/badge/Linux-FCC624?logo=linux&logoColor=black +[arch]: https://img.shields.io/badge/Arch%20Linux-1793D1?logo=arch-linux&logoColor=fff +[fedora]: https://img.shields.io/badge/Fedora-51A2DA?logo=fedora&logoColor=fff +[nixos]: https://img.shields.io/badge/NixOS-5277C3?logo=nixos&logoColor=fff +[debian]: https://img.shields.io/badge/Debian-A81D33?logo=debian&logoColor=fff +[ubuntu]: https://img.shields.io/badge/Ubuntu-E95420?logo=ubuntu&logoColor=fff {/* prettier-ignore-end */} diff --git a/website/versioned_docs/version-latest/reference/environment.mdx b/website/versioned_docs/version-latest/reference/environment.mdx index 40ccfb6344..d6772620c6 100644 --- a/website/versioned_docs/version-latest/reference/environment.mdx +++ b/website/versioned_docs/version-latest/reference/environment.mdx @@ -1,6 +1,6 @@ --- slug: /reference/environment -sidebar_position: 4 +sidebar_position: 5 --- # Environment Reference diff --git a/website/versioned_docs/version-latest/reference/package.mdx b/website/versioned_docs/version-latest/reference/package.mdx new file mode 100644 index 0000000000..1f753897ab --- /dev/null +++ b/website/versioned_docs/version-latest/reference/package.mdx @@ -0,0 +1,29 @@ +--- +slug: /reference/package +sidebar_position: 2 +--- + +# Package API + +:::warning + +**_Task's package API is still experimental and subject to breaking changes._** + +This means that unlike our CLI, we may make breaking changes to the package API +in minor (or even patch) releases. We try to avoid this when possible, but it +may be necessary in order to improve the overall design of the package API. + +In the future we may stabilize the package API. However, this is not currently +planned. For now, if you need to use Task as a Go package, we recommend pinning +the version in your `go.mod` file. Where possible we will try to include a +changelog entry for breaking changes to the package API. + +::: + +Task is primarily a CLI tool that is agnostic of any programming language. +However, it is written in Go and therefore can also be used as a Go package too. +This can be useful if you are already using Go in your project and you need to +extend Task's functionality in some way. + +The full generated documentation for the package API is available on +[pkg.go.dev](https://pkg.go.dev/github.com/go-task/task/v3). diff --git a/website/versioned_docs/version-latest/reference/schema.mdx b/website/versioned_docs/version-latest/reference/schema.mdx index 7066f54504..29dc58c858 100644 --- a/website/versioned_docs/version-latest/reference/schema.mdx +++ b/website/versioned_docs/version-latest/reference/schema.mdx @@ -1,6 +1,6 @@ --- slug: /reference/schema -sidebar_position: 2 +sidebar_position: 3 toc_min_heading_level: 2 toc_max_heading_level: 5 --- @@ -140,7 +140,7 @@ tasks: | `silent` | `bool` | `false` | Skips some output for this command. Note that STDOUT and STDERR of the commands will still be redirected. | | `vars` | [`map[string]Variable`](#variable) | | Optional additional variables to be passed to the referenced task. Only relevant when setting `task` instead of `cmd`. | | `ignore_error` | `bool` | `false` | Continue execution if errors happen while executing the command. | -| `defer` | `string` | | Alternative to `cmd`, but schedules the command to be executed at the end of this task instead of immediately. This cannot be used together with `cmd`. | +| `defer` | [`Defer`](#defer) | | Alternative to `cmd`, but schedules the command or a task to be executed at the end of this task instead of immediately. This cannot be used together with `cmd`. | | `platforms` | `[]string` | All platforms | Specifies which platforms the command should be run on. [Valid GOOS and GOARCH values allowed](https://github.com/golang/go/blob/master/src/internal/syslist/syslist.go). Command will be skipped otherwise. | | `set` | `[]string` | | Specify options for the [`set` builtin](https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html). | | `shopt` | `[]string` | | Specify option for the [`shopt` builtin](https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html). | @@ -180,6 +180,17 @@ tasks: ::: +### Defer + +The `defer` parameter defines a shell command to run, or a task to trigger, at the end of the current task instead of immediately. +If defined as a string this is a shell command, otherwise it is a map defining a task to call: + +| Attribute | Type | Default | Description | +| --------- | ---------------------------------- | ------- | ----------------------------------------------------------------- | +| `task` | `string` | | The deferred task to trigger. | +| `vars` | [`map[string]Variable`](#variable) | | Optional additional variables to be passed to the deferred task. | +| `silent` | `bool` | `false` | Hides task name and command from output. The command's output will still be redirected to `STDOUT` and `STDERR`. | + ### For The `for` parameter can be defined as a string, a list of strings or a map. If diff --git a/website/versioned_docs/version-latest/reference/templating.mdx b/website/versioned_docs/version-latest/reference/templating.mdx index 468a4333b3..98d45bae00 100644 --- a/website/versioned_docs/version-latest/reference/templating.mdx +++ b/website/versioned_docs/version-latest/reference/templating.mdx @@ -1,6 +1,6 @@ --- slug: /reference/templating/ -sidebar_position: 3 +sidebar_position: 4 toc_min_heading_level: 2 toc_max_heading_level: 5 --- @@ -114,6 +114,7 @@ special variable will be overridden. | `ROOT_DIR` | The absolute path of the root Taskfile directory. | | `TASKFILE` | The absolute path of the included Taskfile. | | `TASKFILE_DIR` | The absolute path of the included Taskfile directory. | +| `TASK_DIR` | The absolute path of the directory where the task is executed. | | `USER_WORKING_DIR` | The absolute path of the directory `task` was called from. | | `CHECKSUM` | The checksum of the files listed in `sources`. Only available within the `status` prop and if method is set to `checksum`. | | `TIMESTAMP` | The date object of the greatest timestamp of the files listed in `sources`. Only available within the `status` prop and if method is set to `timestamp`. | diff --git a/website/versioned_docs/version-latest/usage.mdx b/website/versioned_docs/version-latest/usage.mdx index 2f5baa4773..aab62912d1 100644 --- a/website/versioned_docs/version-latest/usage.mdx +++ b/website/versioned_docs/version-latest/usage.mdx @@ -341,43 +341,43 @@ It means that the included Taskfile tasks will be available without the namespac + values={[ + {label: 'Taskfile.yml', value: '1'}, + {label: 'Included.yml', value: '2'} + ]}> - + - ```yaml - version: '3' + ```yaml + version: '3' - includes: - lib: - taskfile: ./Included.yml - flatten: true + includes: + lib: + taskfile: ./Included.yml + flatten: true - tasks: - greet: - cmds: - - echo "Greet" - - task: foo - ``` + tasks: + greet: + cmds: + - echo "Greet" + - task: foo + ``` - - + + - ```yaml - version: '3' + ```yaml + version: '3' - tasks: - foo: - cmds: - - echo "Foo" - ``` + tasks: + foo: + cmds: + - echo "Foo" + ``` - + If you run `task -a` it will print : @@ -393,62 +393,102 @@ You can run `task foo` directly without the namespace. You can also reference the task in other tasks without the namespace. So if you run `task greet` it will run `greet` and `foo` tasks and the output will be : ```text +Greet +Foo ``` If multiple tasks have the same name, an error will be thrown: + values={[ + {label: 'Taskfile.yml', value: '1'}, + {label: 'Included.yml', value: '2'} + ]}> - + ```yaml version: '3' includes: lib: - taskfile: ./Included.yml - flatten: true + taskfile: ./Included.yml + flatten: true - tasks: - greet: - cmds: - - echo "Greet" - - task: foo - ``` + tasks: + greet: + cmds: + - echo "Greet" + - task: foo + ``` - - + + - ```yaml - version: '3' + ```yaml + version: '3' - tasks: - greet: - cmds: - - echo "Foo" - ``` + tasks: + greet: + cmds: + - echo "Foo" + ``` - + If you run `task -a` it will print: ```text task: Found multiple tasks (greet) included by "lib" - ``` +If you the included Taskfile has a task with the same name as a task in the main Taskfile, +you may want to exclude it from the flattened tasks. + +You can do this by using the [`excludes` option](#exclude-tasks-from-being-included). + +### Exclude tasks from being included + +You can exclude tasks from being included by using the `excludes` option. This option takes the list of tasks to be excluded from this include. + + + + + ```yaml + version: '3' + includes: + included: + taskfile: ./Included.yml + excludes: [foo] + ``` + + + + + + ```yaml + version: '3' + + tasks: + foo: echo "Foo" + bar: echo "Bar" + ``` + + +`task included:foo` will throw an error because the `foo` task is excluded but `task included:bar` will work and display `Bar`. +It's compatible with the `flatten` option. ### Vars of included Taskfiles You can also specify variables when including a Taskfile. This may be useful for -having reusable Taskfile that can be tweaked or even included more than once: +having a reusable Taskfile that can be tweaked or even included more than once: ```yaml version: '3' @@ -847,7 +887,7 @@ change even if the source has not. :::tip -The method `none` skips any validation and always run the task. +The method `none` skips any validation and always runs the task. ::: @@ -886,7 +926,7 @@ checksum source and timestamps require either access to the artifact or for an out-of-band refresh of the `.checksum` fingerprint file. Two special variables `{{.CHECKSUM}}` and `{{.TIMESTAMP}}` are available for -interpolation within `status` commands, depending on the method assigned to +interpolation within `cmds` and `status` commands, depending on the method assigned to fingerprint the sources. Only `source` globs are fingerprinted. Note that the `{{.TIMESTAMP}}` variable is a "live" Go `time.Time` struct, and @@ -1028,7 +1068,7 @@ some tasks could have dangerous side effects if run with un-set variables. Using `requires` you specify an array of strings in the `vars` sub-section under `requires`, these strings are variable names which are checked prior to running -the task. If any variables are un-set the the task will error and not run. +the task. If any variables are un-set then the task will error and not run. Environmental variables are also checked.