chore(website): sync translations (#1145)

This commit is contained in:
task-bot
2023-05-06 18:55:50 -03:00
committed by GitHub
parent 7ec5cac56b
commit bf043f411b
36 changed files with 284 additions and 248 deletions

View File

@@ -17,10 +17,12 @@ task [--flags] [tasks...] [-- CLI_ARGS...]
:::tip
如果 `--` 给出,所有剩余参数将被分配给一个特殊的 `CLI_ARGS` 变量
:::
| 缩写 | 标志 | 类型 | 默认 | 描述 |
| ---- | --------------------------- | -------- | -------------------------------- | --------------------------------------------------------------------------------------------------- |
| `-c` | `--color` | `bool` | `true` | 彩色输出。 默认开启。 设置为 `false` 或使用 `NO_COLOR=1` 禁用。 |
@@ -76,9 +78,11 @@ Task 有时会以特定的退出代码退出。 这些代码分为三组,范
这些代码也可以在存储库的 [`errors/errors.go`](https://github.com/go-task/task/blob/main/errors/errors.go) 中找到。
:::info
当使用 `-x`/`--exit-code` 标志运行 Task 时,任何失败命令的退出代码都将传递给用户。
:::
## JSON 输出
`--json` 标志与 `--list``--list-all` 标志结合使用时,将输出具有以下结构的 JSON 对象:
@@ -165,6 +169,7 @@ Task 有时会以特定的退出代码退出。 这些代码分为三组,范
:::info
像下面这样只赋值一个字符串,和把这个值设置到 `taskfile` 属性是一样的。
```yaml
@@ -174,6 +179,7 @@ includes:
:::
### Variable
| 属性 | 类型 | 默认 | 描述 |
@@ -183,6 +189,7 @@ includes:
:::info
静态和动态变量有不同的语法,如下所示:
```yaml
@@ -194,6 +201,7 @@ vars:
:::
### Task
| 属性 | 类型 | 默认 | 描述 |
@@ -225,6 +233,7 @@ vars:
:::info
这些替代语法可用。 他们会将给定值设置为 `cmds`,其他所有内容都将设置为其默认值:
```yaml
@@ -241,6 +250,7 @@ tasks:
:::
#### Command
| 属性 | 类型 | 默认 | 描述 |
@@ -257,6 +267,7 @@ tasks:
:::info
如果以字符串形式给出,该值将分配给 `cmd`
```yaml
@@ -269,6 +280,7 @@ tasks:
:::
#### Dependency
| 属性 | 类型 | 默认 | 描述 |
@@ -278,6 +290,7 @@ tasks:
:::tip
如果你不想设置额外的变量,将依赖关系声明为一个字符串列表就足够了(它们将被分配给 `task`)。
```yaml
@@ -288,6 +301,7 @@ tasks:
:::
#### Precondition
| 属性 | 类型 | 默认 | 描述 |
@@ -297,6 +311,7 @@ tasks:
:::tip
如果你不想设置不同的消息,你可以像这样声明一个前提条件,值将被分配给 `sh`
```yaml

View File

@@ -11,9 +11,9 @@ sidebar_position: 9
[@DeronW](https://github.com/DeronW) 在 [此存储库](https://github.com/DeronW/task) 中维护网站的 [中文翻译](https://task-zh.readthedocs.io/zh_CN/latest/)。
## Integrations
## 集成
Many of our integrations are contributed and maintained by the community. You can view the full list of community integrations [here](./integrations#community-integrations).
我们的许多集成都是由社区贡献和维护的。 您可以在 [此处](/integrations#社区集成) 查看社区集成的完整列表。
## 安装方法

View File

@@ -14,9 +14,9 @@ sidebar_position: 10
## 1. 设置
- **Go** - Task 使用 [Go][go] 编写。 我们始终支持最新的两个主要 Go 版本,因此请确保您的版本足够新。
- **Node.js** - [Node.js][nodejs] 用于托管 Task 的文档服务器,如果您想在本地运行此服务器,则需要它。
- **Yarn** - [Yarn][yarn] 是 Task 使用的 Node.js 包管理器。
- **Go** - Task 使用 [Go](https://go.dev) 编写。 我们始终支持最新的两个主要 Go 版本,因此请确保您的版本足够新。
- **Node.js** - [Node.js](https://nodejs.org/en/) 用于托管 Task 的文档服务器,如果您想在本地运行此服务器,则需要它。
- **Yarn** - [Yarn](https://yarnpkg.com/) 是 Task 使用的 Node.js 包管理器。
## 2. 进行变更
@@ -35,7 +35,7 @@ Task 用 [Docusaurus](https://docusaurus.io) 托管文档服务。 这可以通
进行变更时,请考虑是否有必要更改 [使用指南](./usage.md)。 本文档包含有关如何使用任务功能的说明和示例。 如果您要添加新功能,请尝试找到合适的位置来添加新部分。 如果您要更新现有功能,请确保文档和所有示例都是最新的。 确保任何示例都遵循 [Taskfile 风格指南](./styleguide.md)。
如果您添加了新字段、命令或标志,请确保将其添加到 [API 参考](./api_reference.md) 中。 还需要将新字段添加到 [JSON Schema][json-schema] 中。 API 参考和 schema 中的字段描述应该匹配。
如果您添加了新字段、命令或标志,请确保将其添加到 [API 参考](./api_reference.md) 中。 还需要将新字段添加到 [JSON Schema](https://github.com/go-task/task/blob/main/docs/static/schema.json) 中。 API 参考和 schema 中的字段描述应该匹配。
### 编写测试
@@ -58,24 +58,16 @@ Task 的大部分测试都保存在项目根目录的 `task_test.go` 文件中
> 我想贡献,我从哪里开始?
查看 [未解决 Issue][open-issues] 的列表。 我们有一个 [good first issue][good-first-issue] 标签,用于更简单的问题,非常适合首次贡献。
查看 [未解决 Issue](https://github.com/go-task/task/issues) 的列表。 我们有一个 [good first issue](https://github.com/go-task/task/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) 标签,用于更简单的问题,非常适合首次贡献。
欢迎各种贡献,无论是拼写错误修复还是很小的新功能。 您还可以通过对 Issue 进行投票/评论、帮助回答问题或帮助 [其他社区项目](./community.md) 来做出贡献。
> 我被困住了,我在哪里可以获得帮助?
如果您有任何疑问,请随时在我们的 [Discord 服务器][discord-server] 上的 `#help` 论坛频道中提问,或在 GitHub 上打开 [讨论][discussion]
如果您有任何疑问,请随时在我们的 [Discord 服务器](https://discord.gg/6TY36E39UK) 上的 `#help` 论坛频道中提问,或在 GitHub 上打开 [讨论](https://github.com/go-task/task/discussions)
---
<!-- prettier-ignore-start -->
<!-- prettier-ignore-end -->
[go]: https://go.dev
[nodejs]: https://nodejs.org/en/
[yarn]: https://yarnpkg.com/
[json-schema]: https://github.com/go-task/task/blob/main/docs/static/schema.json
[open-issues]: https://github.com/go-task/task/issues
[good-first-issue]: https://github.com/go-task/task/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22
[discord-server]: https://discord.gg/6TY36E39UK
[discussion]: https://github.com/go-task/task/discussions

View File

@@ -9,7 +9,7 @@ sidebar_position: 13
这只是一种表达“感谢”的方式,它不会给你任何好处,比如在 Issue 上的更高优先级或类似的东西。
每月捐赠至少 50 美元的公司将在网站主页和 GitHub 存储库 README 中被标为“金牌赞助商”。 请与 [@andreynering][] 联系,说明你希望显示的标志。 不过,可疑的企业(赌博、赌场等)将不被允许。
每月捐赠至少 50 美元的公司将在网站主页和 GitHub 存储库 README 中被标为“金牌赞助商”。 请与 [@andreynering](https://github.com/andreynering) 联系,说明你希望显示的标志。 不过,可疑的企业(赌博、赌场等)将不被允许。
## GitHub Sponsors
@@ -30,15 +30,14 @@ sidebar_position: 13
## PayPal
你也可以通过 PayPal 向 [@andreynering][] 捐款。
你也可以通过 PayPal 向 [@andreynering](https://github.com/andreynering) 捐款。
- [任何金额 - 一次性捐款](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=GSVDU63RKG45A&currency_code=USD&source=url)
## PIX (仅巴西)
如果你是巴西人,你也可以通过 PIX [使用这个QR码](/img/pix.png) 向 [@andreynering][] 捐款。
如果你是巴西人,你也可以通过 PIX [使用这个QR码](/img/pix.png) 向 [@andreynering](https://github.com/andreynering) 捐款。
<!-- prettier-ignore-start -->
<!-- prettier-ignore-end -->
[@andreynering]: https://github.com/andreynering

View File

@@ -31,7 +31,7 @@ Windows 上的默认 shell`cmd` 和 `powershell`)没有像 `rm` 和 `cp`
- 使用 `{{OS}}` 函数运行特定于操作系统的脚本。
- 使用 `{{if eq OS "windows"}}powershell {{end}}<my_cmd>` 之类的东西来检测 windows 并直接在 Powershell 中运行命令。
- 在 Windows 上使用支持这些命令的 shell 作为内置命令,例如 [Git Bash][git-bash] 或 [WSL][wsl]
- 在 Windows 上使用支持这些命令的 shell 作为内置命令,例如 [Git Bash](https://gitforwindows.org/) 或 [WSL](https://learn.microsoft.com/en-us/windows/wsl/install)
我们希望对 Task 的这一部分进行改进,下面的 Issue 会跟踪这项工作。 非常欢迎建设性的意见和贡献!
@@ -42,5 +42,3 @@ Windows 上的默认 shell`cmd` 和 `powershell`)没有像 `rm` 和 `cp`
<!-- prettier-ignore-start -->
<!-- prettier-ignore-end -->
[git-bash]: https://gitforwindows.org/
[wsl]: https://learn.microsoft.com/en-us/windows/wsl/install

View File

@@ -27,7 +27,7 @@ brew install go-task
### Snap
Task 在 [Snapcraft][snapcraft] 中可用,但请记住,您的 Linux 发行版应该符合 Snaps 的基本要求才能正确安装:
Task 在 [Snapcraft](https://snapcraft.io/task) 中可用,但请记住,您的 Linux 发行版应该符合 Snaps 的基本要求才能正确安装:
```bash
sudo snap install task --classic
@@ -35,7 +35,7 @@ sudo snap install task --classic
### Chocolatey
如果 Windows 上安装了 [Chocolatey][choco],再安装 Task 只要这样:
如果 Windows 上安装了 [Chocolatey](https://chocolatey.org/),再安装 Task 只要这样:
```bash
choco install go-task
@@ -45,7 +45,7 @@ choco install go-task
### Scoop
如果 Windows 上安装了 [Scoop][scoop],再安装 Task 只要这样:
如果 Windows 上安装了 [Scoop](https://scoop.sh/),再安装 Task 只要这样:
```cmd
scoop install task
@@ -109,7 +109,7 @@ winget install Task.Task
### 二进制文件
您可以从 [GitHub 上的发布页面][releases] 下载二进制文件并添加到您的 `$PATH` 中。
您可以从 [GitHub 上的发布页面](https://github.com/go-task/task/releases) 下载二进制文件并添加到您的 `$PATH` 中。
还支持 DEB 和 RPM 包。
@@ -117,7 +117,7 @@ winget install Task.Task
### 安装脚本
我们还有一个 [安装脚本][installscript],它在 CI 等场景中非常有用。 非常感谢 [GoDownloader](https://github.com/goreleaser/godownloader) 使这个脚本的生成变得容易。
我们还有一个 [安装脚本](https://github.com/go-task/task/blob/main/install-task.sh),它在 CI 等场景中非常有用。 非常感谢 [GoDownloader](https://github.com/goreleaser/godownloader) 使这个脚本的生成变得容易。
默认情况下,它安装在相对于工作目录的 `./bin` 目录中:
@@ -133,10 +133,12 @@ sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
:::caution
在 macOS 和 Windows 上,`~/.local/bin``~/bin` 默认情况下不会添加到 `$PATH`
:::
### GitHub Actions
如果你想在 GitHub Actions 中安装 Task你可以尝试使用 Arduino 团队的 [这个 action](https://github.com/arduino/setup-task)
@@ -155,7 +157,7 @@ sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
### Go Modules
确保您已正确安装和设置受支持的 [Go][go] 版本。 您可以在 [go.mod](https://github.com/go-task/task/blob/main/go.mod#L3) 文件中找到最低要求的 Go 版本。
确保您已正确安装和设置受支持的 [Go](https://golang.org/) 版本。 您可以在 [go.mod](https://github.com/go-task/task/blob/main/go.mod#L3) 文件中找到最低要求的 Go 版本。
然后,您可以通过运行以下命令全局安装最新版本:
@@ -171,10 +173,12 @@ env GOBIN=/bin go install github.com/go-task/task/v3/cmd/task@latest
:::tip
对于 CI 环境,我们建议改用 [安装脚本](#安装脚本),它更快更稳定,因为它只会下载最新发布的二进制文件。
:::
## 自动完成
下载与您的 shell 对应的自动完成文件。
@@ -240,9 +244,3 @@ Invoke-Expression -Command path/to/task.ps1
<!-- prettier-ignore-start -->
<!-- prettier-ignore-end -->
[go]: https://golang.org/
[snapcraft]: https://snapcraft.io/task
[installscript]: https://github.com/go-task/task/blob/main/install-task.sh
[releases]: https://github.com/go-task/task/releases
[choco]: https://chocolatey.org/
[scoop]: https://scoop.sh/

View File

@@ -3,32 +3,32 @@ slug: /integrations/
sidebar_position: 5
---
# Integrations
# 集成
## Visual Studio Code Extension
## Visual Studio Code 扩展
Task has an [official extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=task.vscode-task). The code for this project can be found [here](https://github.com/go-task/vscode-task). To use this extension, you must have Task v3.23.0+ installed on your system.
Task 有一个 [针对 Visual Studio Code 的官方扩展](https://marketplace.visualstudio.com/items?itemName=task.vscode-task)。 这个项目的代码可以在 [这里](https://github.com/go-task/vscode-task) 找到。 要使用此扩展,您的系统上必须安装 Task v3.23.0+。
This extension provides the following features (and more):
此扩展提供以下功能(以及更多):
- View tasks in the sidebar.
- Run tasks from the sidebar and command palette.
- Go to definition from the sidebar and command palette.
- Run last task command.
- Multi-root workspace support.
- Initialize a Taskfile in the current workspace.
- 在侧边栏中查看 task。
- 从侧边栏和命令面板运行 task。
- 从侧边栏和命令面板转到定义。
- 运行上一个 task 命令。
- 多根工作区支持。
- 在当前工作空间中初始化一个 Taskfile。
To get autocompletion and validation for your Taskfile, see the [Schema](#schema) section below.
要获得 Taskfile 的自动完成和验证,请参阅下面的 [Schema](#schema) 部分。
![Task for Visual Studio Code](https://github.com/go-task/vscode-task/blob/main/res/preview.png?raw=true)
## Schema
This was initially created by [@KROSF](https://github.com/KROSF) in [this Gist](https://gist.github.com/KROSF/c5435acf590acd632f71bb720f685895) and is now officially maintained in [this file](https://github.com/go-task/task/blob/master/docs/static/schema.json) and made available at https://taskfile.dev/schema.json. This schema can be used to validate Taskfiles and provide autocompletion in many code editors:
这最初是由 [@KROSF](https://github.com/KROSF) [这个 Gist](https://gist.github.com/KROSF/c5435acf590acd632f71bb720f685895) 中创建的,现在在 [这个](https://github.com/go-task/task/blob/main/docs/static/schema.json) 文件中正式维护,并在 https://taskfile.dev/schema.json 上提供。 这个 schema 可用于验证 Taskfile 并在许多代码编辑器中提供自动完成功能:
### Visual Studio Code
To integrate the schema into VS Code, you need to install the [YAML extension](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) by Red Hat. Any `Taskfile.yml` in your project should automatically be detected and validation/autocompletion should work. If this doesn't work or you want to manually configure it for files with a different name, you can add the following to your `settings.json`:
要将 schema 集成到 VS Code 中,您需要安装 Red Hat 的 [YAML 扩展](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml)。 项目中的任何 `Taskfile.yml` 都应该被自动检测到,并且验证/自动完成应该可以工作。 如果这不起作用或者您想为具有不同名称的文件手动配置它,您可以将以下内容添加到您的 `settings.json`
```json
// settings.json
@@ -42,21 +42,21 @@ To integrate the schema into VS Code, you need to install the [YAML extension](h
}
```
You can also configure the schema directly inside of a Taskfile by adding the following comment to the top of the file:
您还可以通过将以下注释添加到文件顶部来直接在 Taskfile 中配置 schema
```yaml
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: '3'
```
You can find more information on this in the [YAML language server project](https://github.com/redhat-developer/yaml-language-server).
您可以在 [YAML 语言服务器项目](https://github.com/redhat-developer/yaml-language-server) 中找到更多相关信息。
## Community Integrations
## 社区集成
In addition to our official integrations, there is an amazing community of developers who have created their own integrations for Task:
除了我们的官方集成之外,还有一个很棒的开发人员社区,他们为 Task 创建了自己的集成:
- [Sublime Text Plugin](https://packagecontrol.io/packages/Taskfile) [[source](https://github.com/biozz/sublime-taskfile)] by [@biozz](https://github.com/biozz)
- [IntelliJ Plugin](https://plugins.jetbrains.com/plugin/17058-taskfile) [[source](https://github.com/lechuckroh/task-intellij-plugin)] by [@lechuckroh](https://github.com/lechuckroh)
- [mk](https://github.com/pycontribs/mk) command line tool recognizes Taskfiles natively.
- [Sublime Text Plugin](https://packagecontrol.io/packages/Taskfile) [[源码](https://github.com/biozz/sublime-taskfile)] [@biozz](https://github.com/biozz)
- [IntelliJ Plugin](https://plugins.jetbrains.com/plugin/17058-taskfile) [[源码](https://github.com/lechuckroh/task-intellij-plugin)] [@lechuckroh](https://github.com/lechuckroh)
- [mk](https://github.com/pycontribs/mk) 命令行工具本机识别 Taskfile。
If you have made something that integrates with Task, please feel free to open a PR to add it to this list.
如果你做了一些与 Task 集成的东西,请随意打开一个 PR 将它添加到这个列表中。

View File

@@ -10,11 +10,11 @@ title: 主页
<img id="logo" src="img/logo.svg" height="250px" width="250px" />
</div>
Task 是一个任务运行器/构建工具,旨在比 [GNU Make][make] 等更简单易用。
Task 是一个任务运行器/构建工具,旨在比 [GNU Make](https://www.gnu.org/software/make/) 等更简单易用。
由于它是用 [Go](https://go.dev/) 编写的Task 只是一个二进制文件,没有其他依赖项,这意味着您不需要为了使用构建工具而烦恼任何复杂的安装设置。
[安装](installation.md) 后,您只需在名为 `Taskfile.yml` 的文件中使用简单的 [YAML][yaml] 规则描述您的构建任务:
[安装](installation.md) 后,您只需在名为 `Taskfile.yml` 的文件中使用简单的 [YAML](http://yaml.org/) 规则描述您的构建任务:
```yaml title="Taskfile.yml"
version: '3'
@@ -50,5 +50,3 @@ tasks:
<!-- prettier-ignore-start -->
<!-- prettier-ignore-end -->
[make]: https://www.gnu.org/software/make/
[yaml]: http://yaml.org/

View File

@@ -5,7 +5,7 @@ sidebar_position: 11
# 发布
Task 的发布流程是在 [GoReleaser][goreleaser] 的帮助下完成的。 本地调用 Taskfile 的 `test-release` task 可以测试发布流程。
Task 的发布流程是在 [GoReleaser](https://goreleaser.com/) 的帮助下完成的。 本地调用 Taskfile 的 `test-release` task 可以测试发布流程。
[GitHub Actions](https://github.com/go-task/task/actions) 会在新 tag 推送到 `main` 分支的时候自动发布产出物原生的可执行文件、DEB 和 RPM 包)。
@@ -17,14 +17,14 @@ Goreleaser 会自动向 [Homebrew tap](https://github.com/go-task/homebrew-tap)
# npm
要发布到 npm ,请更新 [`package.json`][packagejson] 文件中的版本,然后运行 `task npm:publish` 来推送它。
要发布到 npm ,请更新 [`package.json`](https://github.com/go-task/task/blob/main/package.json#L3) 文件中的版本,然后运行 `task npm:publish` 来推送它。
# Snapcraft
[snap package](https://github.com/go-task/snap) 发布新版本需要手动执行下面步骤:
- 更新 [snapcraft.yaml](https://github.com/go-task/snap/blob/master/snap/snapcraft.yaml#L2) 文件中的版本。
- 把新的 `amd64`, `armhf``arm64` 移动到 [Snapcraft dashboard][snapcraftdashboard] 的稳定通道。
- 把新的 `amd64`, `armhf``arm64` 移动到 [Snapcraft dashboard](https://snapcraft.io/task/releases) 的稳定通道。
# Scoop
@@ -37,6 +37,3 @@ Nix 安装由社区维护。 Nix 包的维护人员通常会在 [这个文件](h
<!-- prettier-ignore-start -->
<!-- prettier-ignore-end -->
[goreleaser]: https://goreleaser.com/
[packagejson]: https://github.com/go-task/task/blob/main/package.json#L3
[snapcraftdashboard]: https://snapcraft.io/task/releases

View File

@@ -89,7 +89,7 @@ tasks:
## 版本 2.1
2.1 版包括一个全局 `output` 选项,以允许更好地控制如何将命令输出打印到控制台(有关更多信息,请参阅 [文档][output]
2.1 版包括一个全局 `output` 选项,以允许更好地控制如何将命令输出打印到控制台(有关更多信息,请参阅 [文档](usage.md#输出语法)
```yaml
version: '2'
@@ -103,7 +103,7 @@ tasks:
prefix: server
```
从这个版本开始,也可以忽略命令或 task 的错误(在 [此处][ignore_errors] 查看文档):
从这个版本开始,也可以忽略命令或 task 的错误(在 [此处](usage.md#忽略错误) 查看文档):
```yaml
version: '2'
@@ -149,7 +149,7 @@ tasks:
- aws s3 cp .env s3://myenvironment
```
请检查 [文档][includes]
请检查 [文档](usage.md#包含其他-taskfile)
## 版本 3
@@ -202,7 +202,3 @@ tasks:
- 全局或 CLI 变量
- 调用变量
- Task 内的变量
[output]: usage.md#输出语法
[ignore_errors]: usage.md#忽略错误
[includes]: usage.md#包含其他-taskfile

View File

@@ -7,12 +7,10 @@ sidebar_position: 14
想帮助我们翻译此文档吗? 在本文档中,我们解释了如何解决这一问题。
不要直接在 GitHub 存储库上编辑翻译后的 markdown 文件! 我们使用 [Crowdin][crowdin] 来允许贡献者进行翻译工作。 存储库会根据 Crowdin 的进展定期更新。
不要直接在 GitHub 存储库上编辑翻译后的 markdown 文件! 我们使用 [Crowdin](https://crowdin.com/project/taskfile) 来允许贡献者进行翻译工作。 存储库会根据 Crowdin 的进展定期更新。
如果您想访问 Crowdin 项目以提供翻译建议,请在 [我们的 Discord 服务器上的 #translations 频道][discord] 上申请访问权限。 如果给定的语言尚未显示给 Crowdin请询问我们可以对其进行配置。
如果您想访问 Crowdin 项目以提供翻译建议,请在 [我们的 Discord 服务器上的 #translations 频道](https://discord.gg/6TY36E39UK) 上申请访问权限。 如果给定的语言尚未显示给 Crowdin请询问我们可以对其进行配置。
<!-- prettier-ignore-start -->
<!-- prettier-ignore-end -->
[crowdin]: https://crowdin.com/project/taskfile
[discord]: https://discord.gg/6TY36E39UK

View File

@@ -71,6 +71,7 @@ tasks:
:::info
当使用 `-g` 运行全局 Taskfile 时task 将默认在 `$HOME` 上运行,而不是在您的工作目录上!
如前一节所述,`{{.USER_WORKING_DIR}}` 特殊变量在这里可以非常方便地在您从中调用 `task -g` 的目录中运行内容。
@@ -91,6 +92,7 @@ tasks:
:::
## 环境变量
### Task
@@ -124,10 +126,12 @@ tasks:
:::info
`env` 支持扩展和检索 shell 命令的输出,就像变量一样,如您在 [变量](#变量) 部分中看到的那样。
:::
### .env 文件
您还可以使用 `dotenv:` 设置要求 tasks 包含 `.env` 之类的文件
@@ -188,10 +192,12 @@ tasks:
:::info
请注意,您目前无法在包含的 Taskfile 中使用 `dotenv` 键。
:::
## 包含其他 Taskfile
如果要在不同项目Taskfile之间共享任务可以使用导入机制使用 `includes` 关键字包含其他任务文件:
@@ -204,7 +210,7 @@ includes:
docker: ./DockerTasks.yml
```
给定的 Taskfile 中描述的任务将在指定的命名空间中提供。 因此,您可以从 `documentation/Taskfile.yml` 调用 `task docs:serve` 运行 `serve` task或者从 `DockerTasks.yml` 文件调用 `task docker:build` 运行 `build` task。
给定的 Taskfile 中描述的任务将在指定的命名空间中提供。 因此,您可以调用 `task docs:serve` 从 `documentation/Taskfile.yml` 运行 `serve` task或者调用 `task docker:build` 从 `DockerTasks.yml` 文件运行 `build` task。
相对路径是相对于包含包含 Taskfile 的目录解析的。
@@ -234,10 +240,12 @@ includes:
:::info
包含的 Taskfile 必须使用与主 Taskfile 使用的相同规则版本。
:::
### 可选 includes
如果包含文件丢失,标记为可选的包含将允许 task 继续正常执行。
@@ -304,10 +312,12 @@ includes:
:::info
在包含的 Taskfile 中声明的变量优先于包含 Taskfile 中的变量! 如果您希望包含的 Taskfile 中的变量可被覆盖,请使用 [默认方法](https://go-task.github.io/slim-sprig/defaults.html)`MY_VAR: '{{.MY_VAR | default "my-default-value"}}'`。
:::
## 内部 tasks
内部 task 是用户不能直接调用的 task。 运行 `task --list|--list-all` 时,它们不会出现在输出中。 其他 task 可以照常调用内部 task。 这对于创建在命令行上没有用处的可重用、类似函数的 task 很有用。
@@ -389,10 +399,12 @@ tasks:
:::tip
您还可以使用 `--parallel` 标志(别名 `-p`)使命令行给出的 task 并行运行。 例如: `task --parallel js css`。
:::
如果你想将信息传递给依赖项,你可以像 [调用另一个 task](#调用另一个-task) 一样以相同的方式进行:
```yaml
@@ -525,10 +537,12 @@ tasks:
:::tip
注意:如果您想从 [包含的 Taskfile](#包含其他-taskfile) 中调用在根 Taskfile 中声明的 task请像这样添加 `:` 前缀:`task: :task-name`。
:::
## 减少不必要的工作
### 通过指纹识别本地生成的文件及其来源
@@ -583,7 +597,8 @@ tasks:
:::info
默认情况task 在本地项目的 `.task` 目录保存 checksums 值。 一般都会在 `.gitignore`(或类似配置)中忽略掉这个目录,这样它就不会被提交。 (If you have a task for code generation that is committed it may make sense to commit the checksum of that task as well, though).
默认情况task 在本地项目的 `.task` 目录保存 checksums 值。 一般都会在 `.gitignore`(或类似配置)中忽略掉这个目录,这样它就不会被提交。 (如果您有一个已提交的代码生成任务,那么提交该任务的校验和也是有意义的)。
如果你想要将这些文件存储在另一个目录中,你可以在你的机器中设置一个 `TASK_TEMP_DIR` 环境变量。 可以使用相对路径,比如 `tmp/task`,相对项目根目录,也可以用绝对路径、用户目录路径,比如 `/tmp/.task` 或 `~/.task`(每个项目单独创建子目录)。
@@ -593,29 +608,36 @@ export TASK_TEMP_DIR='~/.task'
:::
:::info
Each task has only one checksum stored for its `sources`. If you want to distinguish a task by any of its input variables, you can add those variables as part of the task's label, and it will be considered a different task.
This is useful if you want to run a task once for each distinct set of inputs until the sources actually change. For example, if the sources depend on the value of a variable, or you if you want the task to rerun if some arguments change even if the source has not.
每个 task 只为其 `sources` 存储一个 checksum。 如果您想通过任何输入变量来区分 task您可以将这些变量添加为 task 标签的一部分,它将被视为不同的 task。
如果您想为每个不同的输入集运行一次 task直到 sources 实际发生变化,这将很有用。 例如,如果 sources 依赖于变量的值,或者您希望在某些参数发生变化时重新运行 task即使 sources 没有发生变化也是如此。
:::
:::tip
将 method 设置为 `none` 会跳过任何验证并始终运行任务。
:::
:::info
For the `checksum` (default) or `timestamp` method to work, it is only necessary to inform the source files. When the `timestamp` method is used, the last time of the running the task is considered as a generate.
要使 `checksum`(默认)或 `timestamp` 方法起作用,只需要通知 source 文件即可。 当使用 `timestamp` 方法时,最后一次运行 task 被认为是一次生成。
:::
### 使用程序检查来表示任务是最新的
Alternatively, you can inform a sequence of tests as `status`. If no error is returned (exit status 0), the task is considered up-to-date:
或者,您可以通知一系列测试作为 `status`。 如果没有错误返回(退出状态 0task 被认为是最新的:
```yaml
version: '3'
@@ -639,7 +661,7 @@ Two special variables `{{.CHECKSUM}}` and `{{.TIMESTAMP}}` are available for int
Note that the `{{.TIMESTAMP}}` variable is a "live" Go `time.Time` struct, and can be formatted using any of the methods that `time.Time` responds to.
See [the Go Time documentation](https://golang.org/pkg/time/) for more information.
有关详细信息,请参阅 [Go Time 文档](https://golang.org/pkg/time/)
如果你想强制任务运行,即使是最新的,你也可以使用 `--force` 或 `-f`。
@@ -687,7 +709,7 @@ tasks:
msg: "One doesn't equal Zero, Halting"
```
Preconditions can set specific failure messages that can tell a user what steps to take using the `msg` field.
先决条件可以设置特定的失败消息,这些消息可以使用 `msg` 字段告诉用户要采取什么步骤。
If a task has a dependency on a sub-task with a precondition, and that precondition is not met - the calling task will fail. Note that a task executed with a failing precondition will not run unless `--force` is given.
@@ -749,11 +771,11 @@ tasks:
## 变量
在进行变量插值时Task 将查找以下内容。 They are listed below in order of importance (i.e. most important first):
在进行变量插值时Task 将查找以下内容。 它们按权重顺序列在下面(即最重要的第一位):
- Variables declared in the task definition
- Variables given while calling a task from another (See [Calling another task](#calling-another-task) above)
- Variables of the [included Taskfile](#including-other-taskfiles) (when the task is included)
- task 内部定义的变量
- 被其它 task 调用时传入的变量(查看 [调用另一个 task](#调用另一个-task))
- [包含其他 Taskfile](#包含其他-taskfile) 中的变量 (当包含其他 task 时)
- Variables of the [inclusion of the Taskfile](#vars-of-included-taskfiles) (when the task is included)
- Global variables (those declared in the `vars:` option in the Taskfile)
- Environment variables
@@ -766,10 +788,12 @@ $ TASK_VARIABLE=a-value task do-something
:::tip
A special variable `.TASK` is always available containing the task name.
:::
Since some shells do not support the above syntax to set environment variables (Windows) tasks also accept a similar style when not at the beginning of the command.
```bash
@@ -874,13 +898,15 @@ tasks:
:::info
Due to the nature of how the [Go's own `defer` work](https://go.dev/tour/flowcontrol/13), the deferred commands are executed in the reverse order if you schedule multiple of them.
:::
## Go 的模板引擎
Task 在执行命令之前将命令解析为 [Go 的模板引擎][gotemplate]。 可以通过点语法 (`.VARNAME`) 访问变量。
Task 在执行命令之前将命令解析为 [Go 的模板引擎](https://golang.org/pkg/text/template/)。 可以通过点语法 (`.VARNAME`) 访问变量。
All functions by the Go's [slim-sprig lib](https://go-task.github.io/slim-sprig/) are available. The following example gets the current date in a given format:
@@ -1265,10 +1291,12 @@ $ task default
:::tip
The `output` option can also be specified by the `--output` or `-o` flags.
:::
## 交互式 CLI 应用
When running interactive CLI applications inside Task they can sometimes behave weirdly, especially when the [output mode](#output-syntax) is set to something other than `interleaved` (the default), or when interactive apps are run in parallel with other tasks.
@@ -1319,10 +1347,12 @@ tasks:
:::info
Keep in mind that not all options are available in the [shell interpreter library](https://github.com/mvdan/sh) that Task uses.
:::
## 观察任务
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, so task knows which files to watch.
@@ -1332,4 +1362,3 @@ The default watch interval is 5 seconds, but it's possible to change it by eithe
<!-- prettier-ignore-start -->
<!-- prettier-ignore-end -->
[gotemplate]: https://golang.org/pkg/text/template/