diff --git a/zh-Hans/404.html b/zh-Hans/404.html index e59c95a9..0649cf30 100644 --- a/zh-Hans/404.html +++ b/zh-Hans/404.html @@ -10,13 +10,13 @@ - +
跳到主要内容

找不到页面

我们找不到您要找的页面。

请联系原始链接来源网站的所有者,并告知他们链接已损坏。

- + \ No newline at end of file diff --git a/zh-Hans/api/index.html b/zh-Hans/api/index.html index 82e8ec3b..9b57267e 100644 --- a/zh-Hans/api/index.html +++ b/zh-Hans/api/index.html @@ -10,13 +10,13 @@ - +
跳到主要内容

API 参考

命令行

该命令的语法如下:

task [--flags] [tasks...] [-- CLI_ARGS...]
提示

如果 -- 给出,所有剩余参数将被分配给一个特殊的 CLI_ARGS 变量

缩写标志类型默认描述
-c--colorbooltrue彩色输出。 默认开启。 设置为 false 或使用 NO_COLOR=1 禁用。
-C--concurrencyint0限制并发运行的任务数。 零意味着无限。
-d--dirstring工作目录设置执行目录。
-n--dryboolfalse按运行顺序编译和打印任务,而不执行它们。
-x--exit-codeboolfalse传递任务命令的退出代码。
-f--forceboolfalse即使任务是最新的也强制执行。
-g--globalboolfalse$HOME/Taskfile.{yml,yaml} 运行全局任务文件。
-h--helpboolfalse显示任务使用情况。
-i--initboolfalse在当前目录创建一个新的 Taskfile.yml。
-I--intervalstring5s使用 --watch 设置不同的观察间隔,默认为 5 秒。 这个字符串应该是一个有效的 Go Duration
-l--listboolfalse列出当前文件的全部任务及对应描述。
-a--list-allboolfalse列出无论有没有描述的所有任务。
--jsonboolfalse查看 JSON 输出
-o--outputstring在 Taskfile 中设置默认值或 intervealed设置输出样式:[interleaved/group/prefixed]
--output-group-beginstring在任务组输出前打印的消息模板。
--output-group-endstring在任务组输出后打印的消息模板。
--output-group-error-onlyboolfalse在退出码为 0 时忽略命令输出。
-p--parallelboolfalse并行执行命令行上提供的任务。
-s--silentboolfalse禁用回显。
--statusboolfalse如果任何给定任务不是最新的,则以非 0 退出码退出。
--summaryboolfalse显示有关任务的摘要。
-t--taskfilestringTaskfile.ymlTaskfile.yaml
-v--verboseboolfalse启用详细模式。
--versionboolfalse显示 Task 版本。
-w--watchboolfalse启用给定任务的观察器。

JSON 输出

--json 标志与 --list--list-all 标志结合使用时,将输出具有以下结构的 JSON 对象:

{
"tasks": [
{
"name": "",
"desc": "",
"summary": "",
"up_to_date": false,
"location": {
"line": 54,
"column": 3,
"taskfile": "/path/to/Taskfile.yml"
}
},
// ...
],
"location": "/path/to/Taskfile.yml"
}

特殊变量

模板系统上有一些可用的特殊变量:

变量描述
CLI_ARGS当通过 CLI 调用 Task 时,传递包含在 -- 之后的所有额外参数。
TASK当前任务的名称。
ROOT_DIR根 Taskfile 的绝对路径。
TASKFILE_DIR包含 Taskfile 的绝对路径
USER_WORKING_DIR调用 task 的目录的绝对路径。
CHECKSUMsources 中列出的文件的 checksum。 仅在 status 参数中可用,并且如果方法设置为 checksum
TIMESTAMPsources 中列出的文件的最大时间戳的日期对象。 仅在 status 参数中可用,并且如果方法设置为 timestamp
TASK_VERSIONTask 的当前版本。

环境变量

可以覆盖某些环境变量以调整 Task 行为。

环境变量默认描述
TASK_TEMP_DIR.task临时目录的位置。 可以相对于项目比如 tmp/task 或绝对如 /tmp/.task~/.task
TASK_COLOR_RESET0用于白色的颜色。
TASK_COLOR_BLUE34用于蓝色的颜色。
TASK_COLOR_GREEN32用于绿色的颜色。
TASK_COLOR_CYAN36用于青色的颜色。
TASK_COLOR_YELLOW33用于黄色的颜色。
TASK_COLOR_MAGENTA35用于洋红色的颜色。
TASK_COLOR_RED31用于红色的颜色。
FORCE_COLOR强制使用颜色输出。

Taskfile Schema

属性类型默认描述
versionstringTaskfile 的版本。 当前版本是 3
outputstringinterleaved输出模式。 可用选项: interleavedgroupprefixed
methodstringchecksumTaskfile 中的默认方法。 可以在任务基础上覆盖。 可用选项:checksumtimestampnone
includesmap[string]Include要包含的其他 Taskfile。
varsmap[string]Variable一组全局变量。
envmap[string]Variable一组全局环境变量。
tasksmap[string]Task一组任务定义。
silentboolfalse此任务文件的默认“silent”选项。 如果为 false,则可以在任务的基础上用 true 覆盖。
dotenv[]string要解析的 .env 文件路径列表。
runstringalwaysTaskfile 中默认的 'run' 选项。 可用选项: alwaysoncewhen_changed
intervalstring5s设置 --watch 模式下的观察时间,默认 5 秒。 这个字符串应该是一个有效的 Go Duration
set[]string内置 set 指定选项。
shopt[]string内置 shopt 指定选项。

Include

属性类型默认描述
taskfilestring要包含的 Taskfile 或目录的路径。 如果是目录,Task 将在该目录中查找名为 Taskfile.ymlTaskfile.yaml 的文件。 如果是相对路径,则相对于包含 Taskfile 的目录进行解析。
dirstringTaskfile 文件父目录运行时包含的任务的工作目录。
optionalboolfalse设置为 true 时, 文件不存在也不会报错
internalboolfalse停止在命令行上调用包含的任务文件中的任何任务。 当与 --list 一起使用时,这些命令也将从输出中省略。
aliases[]string包含的 Taskfile 的命名空间的替代名称。
varsmap[string]Variable一组应用于包含的 Taskfile 的变量。
信息

像下面这样只赋值一个字符串,和把这个值设置到 taskfile 属性是一样的。

includes:
foo: ./path

Variable

属性类型默认描述
itselfstring将设置为变量的静态值。
shstring一个 shell 命令。 输出 (STDOUT) 将分配给变量。
信息

静态和动态变量有不同的语法,如下所示:

vars:
STATIC: static
DYNAMIC:
sh: echo "dynamic"

Task

属性类型默认描述
cmds[]Command要执行的 shell 命令列表。
deps[]Dependency此任务的依赖项列表。 此处定义的任务将在此任务之前并行运行。
labelstring运行任务时覆盖输出中的任务名称。 支持变量。
descstringTask 的简短描述。 这在调用 task --list 时显示。
summarystring任务的较长描述。 这在调用 task --summary [task] 时显示。
aliases[]string可以调用任务的别名列表。
sources[]string运行此任务之前要检查的源列表。 与 checksumtimestamp 相关。 可以是文件路径或星号。
generates[]string此任务要生成的文件列表。 与 timestamp 方法相关。 可以是文件路径或星号。
status[]string用于检查此 task 是否应运行的命令列表。 否则跳过该任务。 这个方法会覆盖 methodsourcesgenerates
preconditions[]Precondition用于检查此任务是否应运行的命令列表。 如果不满足条件,任务将出错。
dirstring此 task 应运行的目录。 默认为当前工作目录。
varsmap[string]Variable可在 task 中使用的一组变量。
envmap[string]Variable一组可用于 shell 命令的环境变量。
dotenv[]string要解析的 .env 文件路径列表。
silentboolfalse从输出中隐藏任务名称和命令。 命令的输出仍将重定向到 STDOUTSTDERR。 当与 --list 标志结合使用时,任务描述将被隐藏。
interactiveboolfalse告诉任务该命令是交互式的。
internalboolfalse停止在命令行上调用任务。 当与 --list 一起使用时,它也会从输出中省略。
methodstringchecksum定义用于检查任务是最新的方法。 timestamp 将比较源的时间戳并生成文件。 checksum 将检查 checksum(您可能想忽略 .gitignore 文件中的 .task 文件夹)。 none 跳过任何验证并始终运行任务。
prefixstring定义一个字符串作为并行运行 task 输出的前缀。 仅在输出模式是 prefixed 时使用。
ignore_errorboolfalse如果执行命令时发生错误,则继续执行。
runstringTaskfile 中全局声明的值或 always指定如果多次调用该任务是否应再次运行。 可用选项:alwaysoncewhen_changed
platforms[]string所有平台指定应在哪些平台上运行任务。 允许使用 有效的 GOOS 和 GOARCH 值。 否则将跳过任务。
set[]string内置 set 指定选项。
shopt[]string内置 shopt 指定选项。
信息

这些替代语法可用。 他们会将给定值设置为 cmds,其他所有内容都将设置为其默认值:

tasks:
foo: echo "foo"

foobar:
- echo "foo"
- echo "bar"

baz:
cmd: echo "baz"

Command

属性类型默认描述
cmdstring要执行的 shell 命令
silentboolfalse跳过此命令的一些输出。 请注意,命令的 STDOUT 和 STDERR 仍将被重定向。
taskstring执行另一个 task,而不执行命令。 不能与 cmd 同时设置。
varsmap[string]Variable要传递给引用任务的可选附加变量。 仅在设置 task 而不是 cmd 时相关。
ignore_errorboolfalse执行命令的时候忽略错误,继续执行
deferstringcmd 的替代方法,但安排命令在此任务结束时执行,而不是立即执行。 不能与 cmd 一同使用。
platforms[]string所有平台指定应在哪些平台上运行该命令。 允许使用 有效的 GOOS 和 GOARCH 值。 否则将跳过命令。
set[]string内置 set 指定选项。
shopt[]string内置 shopt 指定选项。
信息

如果以字符串形式给出,该值将分配给 cmd

tasks:
foo:
cmds:
- echo "foo"
- echo "bar"

Dependency

属性类型默认描述
taskstring要作为依赖项执行的任务。
varsmap[string]Variable要传递给此任务的可选附加变量。
提示

如果你不想设置额外的变量,将依赖关系声明为一个字符串列表就足够了(它们将被分配给 task)。

tasks:
foo:
deps: [foo, bar]

Precondition

属性类型默认描述
shstring要执行的命令。 如果返回非零退出码,任务将在不执行其命令的情况下出错。
msgstring如果不满足先决条件,则打印可选消息。
提示

如果你不想设置不同的消息,你可以像这样声明一个前提条件,值将被分配给 sh

tasks:
foo:
precondition: test -f Taskfile.yml
- + \ No newline at end of file diff --git a/zh-Hans/assets/js/01713e21.3f827c94.js b/zh-Hans/assets/js/01713e21.3f827c94.js deleted file mode 100644 index d71fb6f4..00000000 --- a/zh-Hans/assets/js/01713e21.3f827c94.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktaskfile_dev=self.webpackChunktaskfile_dev||[]).push([[701],{3905:function(e,n,t){t.d(n,{Zo:function(){return d},kt:function(){return c}});var a=t(7294);function l(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function s(e){for(var n=1;n=0||(l[t]=e[t]);return l}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(l[t]=e[t])}return l}var r=a.createContext({}),p=function(e){var n=a.useContext(r),t=n;return e&&(t="function"==typeof e?e(n):s(s({},n),e)),t},d=function(e){var n=p(e.components);return a.createElement(r.Provider,{value:n},e.children)},k="mdxType",m={inlineCode:"code",wrapper:function(e){var n=e.children;return a.createElement(a.Fragment,{},n)}},u=a.forwardRef((function(e,n){var t=e.components,l=e.mdxType,i=e.originalType,r=e.parentName,d=o(e,["components","mdxType","originalType","parentName"]),k=p(t),u=l,c=k["".concat(r,".").concat(u)]||k[u]||m[u]||i;return t?a.createElement(c,s(s({ref:n},d),{},{components:t})):a.createElement(c,s({ref:n},d))}));function c(e,n){var t=arguments,l=n&&n.mdxType;if("string"==typeof e||l){var i=t.length,s=new Array(i);s[0]=u;var o={};for(var r in n)hasOwnProperty.call(n,r)&&(o[r]=n[r]);o.originalType=e,o[k]="string"==typeof e?e:l,s[1]=o;for(var p=2;pdefer \u505a task \u6e05\u7406",id:"\u4f7f\u7528-defer-\u505a-task-\u6e05\u7406",level:2},{value:"Go \u7684\u6a21\u677f\u5f15\u64ce",id:"go-\u7684\u6a21\u677f\u5f15\u64ce",level:2},{value:"\u5e2e\u52a9",id:"\u5e2e\u52a9",level:2},{value:"\u663e\u793a\u4efb\u52a1\u6458\u8981",id:"\u663e\u793a\u4efb\u52a1\u6458\u8981",level:2},{value:"Task \u522b\u540d",id:"task-\u522b\u540d",level:2},{value:"\u91cd\u5199 Task \u540d\u79f0",id:"\u91cd\u5199-task-\u540d\u79f0",level:2},{value:"\u9759\u9ed8\u6a21\u5f0f",id:"\u9759\u9ed8\u6a21\u5f0f",level:2},{value:"\u8bd5\u8fd0\u884c\u6a21\u5f0f",id:"\u8bd5\u8fd0\u884c\u6a21\u5f0f",level:2},{value:"\u5ffd\u7565\u9519\u8bef",id:"\u5ffd\u7565\u9519\u8bef",level:2},{value:"\u8f93\u51fa\u8bed\u6cd5",id:"\u8f93\u51fa\u8bed\u6cd5",level:2},{value:"\u4ea4\u4e92\u5f0f CLI \u5e94\u7528",id:"\u4ea4\u4e92\u5f0f-cli-\u5e94\u7528",level:2},{value:"\u77ed Task \u8bed\u6cd5",id:"\u77ed-task-\u8bed\u6cd5",level:2},{value:"set \u548c shopt",id:"set-\u548c-shopt",level:2},{value:"\u89c2\u5bdf\u4efb\u52a1",id:"\u89c2\u5bdf\u4efb\u52a1",level:2}],d={toc:p};function k(e){let{components:n,...t}=e;return(0,l.kt)("wrapper",(0,a.Z)({},d,t,{components:n,mdxType:"MDXLayout"}),(0,l.kt)("h1",{id:"\u4f7f\u7528\u6307\u5357"},"\u4f7f\u7528\u6307\u5357"),(0,l.kt)("h2",{id:"\u5feb\u901f\u5165\u95e8"},"\u5feb\u901f\u5165\u95e8"),(0,l.kt)("p",null,"\u5728\u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskfile.yml")," \u7684\u6587\u4ef6\u3002 ",(0,l.kt)("inlineCode",{parentName:"p"},"cmds")," \u5c5e\u6027\u5e94\u5305\u542b task \u7684\u547d\u4ee4\u3002 \u4e0b\u9762\u7684\u793a\u4f8b\u5141\u8bb8\u7f16\u8bd1 Go \u5e94\u7528\u7a0b\u5e8f\u5e76\u4f7f\u7528 ",(0,l.kt)("a",{parentName:"p",href:"https://esbuild.github.io/"},"esbuild")," \u5c06\u591a\u4e2a CSS \u6587\u4ef6\u5408\u5e76\u5e76\u7f29\u5c0f\u4e3a\u4e00\u4e2a\u6587\u4ef6\u3002"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n cmds:\n - go build -v -i main.go\n\n assets:\n cmds:\n - esbuild --bundle --minify css/index.css > public/bundle.css\n")),(0,l.kt)("p",null,"\u8fd0\u884c task \u5c31\u8fd9\u6837\u7b80\u5355\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"task assets build\n")),(0,l.kt)("p",null,"Task \u4f7f\u7528 ",(0,l.kt)("a",{parentName:"p",href:"https://mvdan.cc/sh/"},"mvdan.cc/sh"),"\uff0c\u4e00\u4e2a\u539f\u751f\u7684 Go sh \u89e3\u91ca\u5668\u3002 \u56e0\u6b64\uff0c\u60a8\u53ef\u4ee5\u7f16\u5199 sh/bash \u547d\u4ee4\uff0c\u5b83\u751a\u81f3\u53ef\u4ee5\u5728 Windows \u4e0a\u8fd0\u884c\uff0c\u800c ",(0,l.kt)("inlineCode",{parentName:"p"},"sh")," \u6216 ",(0,l.kt)("inlineCode",{parentName:"p"},"bash")," \u901a\u5e38\u4e0d\u53ef\u7528\u3002 \u8bf7\u8bb0\u4f4f\uff0c\u4efb\u4f55\u88ab\u8c03\u7528\u7684\u53ef\u6267\u884c\u6587\u4ef6\u90fd\u5fc5\u987b\u5728\u64cd\u4f5c\u7cfb\u7edf\u6216 PATH \u4e2d\u53ef\u7528\u3002"),(0,l.kt)("p",null,'\u5982\u679c\u4e0d\u4f20 task \u7684\u540d\u5b57\uff0c\u9ed8\u8ba4\u4f1a\u8c03\u7528 "default"\u3002'),(0,l.kt)("h2",{id:"\u652f\u6301\u7684\u6587\u4ef6\u540d\u79f0"},"\u652f\u6301\u7684\u6587\u4ef6\u540d\u79f0"),(0,l.kt)("p",null,"Task \u4f1a\u6309\u4ee5\u4e0b\u987a\u5e8f\u67e5\u627e\u914d\u7f6e\u6587\u4ef6:"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"Taskfile.yml"),(0,l.kt)("li",{parentName:"ul"},"Taskfile.yaml"),(0,l.kt)("li",{parentName:"ul"},"Taskfile.dist.yml"),(0,l.kt)("li",{parentName:"ul"},"Taskfile.dist.yaml")),(0,l.kt)("p",null,"\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},".dist")," \u53d8\u4f53\u7684\u76ee\u7684\u662f\u5141\u8bb8\u9879\u76ee\u6709\u4e00\u4e2a\u63d0\u4ea4\u7248\u672c (",(0,l.kt)("inlineCode",{parentName:"p"},".dist"),")\uff0c\u540c\u65f6\u4ecd\u7136\u5141\u8bb8\u4e2a\u4eba\u7528\u6237\u901a\u8fc7\u6dfb\u52a0\u989d\u5916\u7684 ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskfile.yml"),"\uff08\u5c06\u5728 ",(0,l.kt)("inlineCode",{parentName:"p"},".gitignore")," \u4e0a\uff09\u6765\u8986\u76d6 Taskfile\u3002"),(0,l.kt)("h3",{id:"\u4ece\u5b50\u76ee\u5f55\u8fd0\u884c-taskfile"},"\u4ece\u5b50\u76ee\u5f55\u8fd0\u884c Taskfile"),(0,l.kt)("p",null,"\u5982\u679c\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u627e\u4e0d\u5230 Taskfile\uff0c\u5b83\u5c06\u6cbf\u7740\u6587\u4ef6\u6811\u5411\u4e0a\u67e5\u627e\uff0c\u76f4\u5230\u627e\u5230\u4e00\u4e2a\uff08\u7c7b\u4f3c\u4e8e ",(0,l.kt)("inlineCode",{parentName:"p"},"git")," \u7684\u5de5\u4f5c\u65b9\u5f0f\uff09\u3002 \u5f53\u4ece\u8fd9\u6837\u7684\u5b50\u76ee\u5f55\u8fd0\u884c Task \u65f6\uff0c\u5b83\u7684\u884c\u4e3a\u5c31\u50cf\u4ece\u5305\u542b Taskfile \u7684\u76ee\u5f55\u8fd0\u884c\u5b83\u4e00\u6837\u3002"),(0,l.kt)("p",null,"\u60a8\u53ef\u4ee5\u5c06\u6b64\u529f\u80fd\u4e0e\u7279\u6b8a\u7684 ",(0,l.kt)("inlineCode",{parentName:"p"},"{{.USER_WORKING_DIR}}")," \u53d8\u91cf\u4e00\u8d77\u4f7f\u7528\u6765\u521b\u5efa\u4e00\u4e9b\u975e\u5e38\u6709\u7528\u7684\u53ef\u91cd\u7528 task\u3002 \u4f8b\u5982\uff0c\u5982\u679c\u4f60\u6709\u4e00\u4e2a\u5305\u542b\u6bcf\u4e2a\u5fae\u670d\u52a1\u76ee\u5f55\u7684 monorepo\uff0c\u4f60\u53ef\u4ee5 ",(0,l.kt)("inlineCode",{parentName:"p"},"cd")," \u8fdb\u5165\u4e00\u4e2a\u5fae\u670d\u52a1\u76ee\u5f55\u5e76\u8fd0\u884c\u4e00\u4e2a task \u547d\u4ee4\u6765\u542f\u52a8\u5b83\uff0c\u800c\u4e0d\u5fc5\u521b\u5efa\u591a\u4e2a task \u6216\u5177\u6709\u76f8\u540c\u5185\u5bb9\u7684 Taskfile\u3002 \u4f8b\u5982\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n up:\n dir: '{{.USER_WORKING_DIR}}'\n preconditions:\n - test -f docker-compose.yml\n cmds:\n - docker-compose up -d\n")),(0,l.kt)("p",null,"\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u8fd0\u884c ",(0,l.kt)("inlineCode",{parentName:"p"},"cd ")," \u548c ",(0,l.kt)("inlineCode",{parentName:"p"},"task up"),"\uff0c\u53ea\u8981 ",(0,l.kt)("inlineCode",{parentName:"p"},"")," \u76ee\u5f55\u5305\u542b ",(0,l.kt)("inlineCode",{parentName:"p"},"docker-compose.yml"),"\uff0c\u5c31\u4f1a\u542f\u52a8 Docker Compose\u3002"),(0,l.kt)("h3",{id:"\u8fd0\u884c\u5168\u5c40-taskfile"},"\u8fd0\u884c\u5168\u5c40 Taskfile"),(0,l.kt)("p",null,"If you call Task with the ",(0,l.kt)("inlineCode",{parentName:"p"},"--global")," (alias ",(0,l.kt)("inlineCode",{parentName:"p"},"-g"),") flag, it will look for your home directory instead of your working directory. In short, Task will look for a Taskfile on either ",(0,l.kt)("inlineCode",{parentName:"p"},"$HOME/Taskfile.yml")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"$HOME/Taskfile.yaml")," paths."),(0,l.kt)("p",null,"\u8fd9\u5bf9\u4e8e\u60a8\u53ef\u4ee5\u5728\u7cfb\u7edf\u7684\u4efb\u4f55\u5730\u65b9\u8fd0\u884c\u7684\u81ea\u52a8\u5316\u5f88\u6709\u7528\uff01"),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"When running your global Taskfile with ",(0,l.kt)("inlineCode",{parentName:"p"},"-g"),", tasks will run on ",(0,l.kt)("inlineCode",{parentName:"p"},"$HOME")," by default, and not on your working directory!"),(0,l.kt)("p",{parentName:"admonition"},"As mentioned in the previous section, the ",(0,l.kt)("inlineCode",{parentName:"p"},"{{.USER_WORKING_DIR}}")," special variable can be very handy here to run stuff on the directory you're calling ",(0,l.kt)("inlineCode",{parentName:"p"},"task -g")," from."),(0,l.kt)("pre",{parentName:"admonition"},(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n from-home:\n cmds:\n - pwd\n\n from-working-directory:\n dir: '{{.USER_WORKING_DIR}}'\n cmds:\n - pwd\n"))),(0,l.kt)("h2",{id:"\u73af\u5883\u53d8\u91cf"},"\u73af\u5883\u53d8\u91cf"),(0,l.kt)("h3",{id:"task"},"Task"),(0,l.kt)("p",null,"\u4f60\u53ef\u4ee5\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},"env")," \u7ed9\u6bcf\u4e2a task \u8bbe\u7f6e\u81ea\u5b9a\u4e49\u73af\u5883\u53d8\u91cf:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n greet:\n cmds:\n - echo $GREETING\n env:\n GREETING: Hey, there!\n")),(0,l.kt)("p",null,"\u6b64\u5916\uff0c\u60a8\u53ef\u4ee5\u8bbe\u7f6e\u53ef\u7528\u4e8e\u6240\u6709 task \u7684\u5168\u5c40\u73af\u5883\u53d8\u91cf\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nenv:\n GREETING: Hey, there!\n\ntasks:\n greet:\n cmds:\n - echo $GREETING\n")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},(0,l.kt)("inlineCode",{parentName:"p"},"env")," \u652f\u6301\u6269\u5c55\u548c\u68c0\u7d22 shell \u547d\u4ee4\u7684\u8f93\u51fa\uff0c\u5c31\u50cf\u53d8\u91cf\u4e00\u6837\uff0c\u5982\u60a8\u5728 ",(0,l.kt)("a",{parentName:"p",href:"#%E5%8F%98%E9%87%8F"},"\u53d8\u91cf")," \u90e8\u5206\u4e2d\u770b\u5230\u7684\u90a3\u6837\u3002")),(0,l.kt)("h3",{id:"env-\u6587\u4ef6"},".env \u6587\u4ef6"),(0,l.kt)("p",null,"\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},"dotenv:")," \u8bbe\u7f6e\u8981\u6c42 tasks \u5305\u542b ",(0,l.kt)("inlineCode",{parentName:"p"},".env")," \u4e4b\u7c7b\u7684\u6587\u4ef6"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash",metastring:'title=".env"',title:'".env"'},"KEYNAME=VALUE\n")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash",metastring:'title="testing/.env"',title:'"testing/.env"'},"ENDPOINT=testing.com\n")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml",metastring:'title="Taskfile.yml"',title:'"Taskfile.yml"'},"version: '3'\n\nenv:\n ENV: testing\n\ndotenv: ['.env', '{{.ENV}}/.env.', '{{.HOME}}/.env']\n\ntasks:\n greet:\n cmds:\n - echo \"Using $KEYNAME and endpoint $ENDPOINT\"\n")),(0,l.kt)("p",null,"\u4e5f\u53ef\u4ee5\u5728 task \u7ea7\u522b\u6307\u5b9a .env \u6587\u4ef6\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nenv:\n ENV: testing\n\ntasks:\n greet:\n dotenv: ['.env', '{{.ENV}}/.env.', '{{.HOME}}/.env']\n cmds:\n - echo \"Using $KEYNAME and endpoint $ENDPOINT\"\n")),(0,l.kt)("p",null,"\u5728 task \u7ea7\u522b\u660e\u786e\u6307\u5b9a\u7684\u73af\u5883\u53d8\u91cf\u5c06\u8986\u76d6\u70b9\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684\u53d8\u91cf\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nenv:\n ENV: testing\n\ntasks:\n greet:\n dotenv: ['.env', '{{.ENV}}/.env.', '{{.HOME}}/.env']\n env:\n KEYNAME: DIFFERENT_VALUE\n cmds:\n - echo \"Using $KEYNAME and endpoint $ENDPOINT\"\n")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"\u8bf7\u6ce8\u610f\uff0c\u60a8\u76ee\u524d\u65e0\u6cd5\u5728\u5305\u542b\u7684 Taskfile \u4e2d\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},"dotenv")," \u952e\u3002")),(0,l.kt)("h2",{id:"\u5305\u542b\u5176\u4ed6-taskfile"},"\u5305\u542b\u5176\u4ed6 Taskfile"),(0,l.kt)("p",null,"\u5982\u679c\u8981\u5728\u4e0d\u540c\u9879\u76ee\uff08Taskfile\uff09\u4e4b\u95f4\u5171\u4eab\u4efb\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528\u5bfc\u5165\u673a\u5236\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},"includes")," \u5173\u952e\u5b57\u5305\u542b\u5176\u4ed6\u4efb\u52a1\u6587\u4ef6\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n docs: ./documentation # will look for ./documentation/Taskfile.yml\n docker: ./DockerTasks.yml\n")),(0,l.kt)("p",null,"The tasks described in the given Taskfiles will be available with the informed namespace. So, you'd call ",(0,l.kt)("inlineCode",{parentName:"p"},"task docs:serve")," to run the ",(0,l.kt)("inlineCode",{parentName:"p"},"serve")," task from ",(0,l.kt)("inlineCode",{parentName:"p"},"documentation/Taskfile.yml")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"task docker:build")," to run the ",(0,l.kt)("inlineCode",{parentName:"p"},"build")," task from the ",(0,l.kt)("inlineCode",{parentName:"p"},"DockerTasks.yml")," file."),(0,l.kt)("p",null,"\u76f8\u5bf9\u8def\u5f84\u662f\u76f8\u5bf9\u4e8e\u5305\u542b\u5305\u542b Taskfile \u7684\u76ee\u5f55\u89e3\u6790\u7684\u3002"),(0,l.kt)("h3",{id:"\u64cd\u4f5c\u7cfb\u7edf\u7279\u5b9a-taskfile"},"\u64cd\u4f5c\u7cfb\u7edf\u7279\u5b9a Taskfile"),(0,l.kt)("p",null,"With ",(0,l.kt)("inlineCode",{parentName:"p"},"version: '2'"),", task automatically includes any ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskfile_{{OS}}.yml")," if it exists (for example: ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskfile_windows.yml"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskfile_linux.yml")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"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:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n build: ./Taskfile_{{OS}}.yml\n")),(0,l.kt)("h3",{id:"\u5305\u542b-taskfile-\u7684\u76ee\u5f55"},"\u5305\u542b Taskfile \u7684\u76ee\u5f55"),(0,l.kt)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5305\u542b\u7684 Taskfile \u7684 task \u5728\u5f53\u524d\u76ee\u5f55\u4e2d\u8fd0\u884c\uff0c\u5373\u4f7f Taskfile \u5728\u53e6\u4e00\u4e2a\u76ee\u5f55\u4e2d\uff0c\u4f46\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u66ff\u4ee3\u8bed\u6cd5\u5f3a\u5236\u5176 task \u5728\u53e6\u4e00\u4e2a\u76ee\u5f55\u4e2d\u8fd0\u884c\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n docs:\n taskfile: ./docs/Taskfile.yml\n dir: ./docs\n")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"\u5305\u542b\u7684 Taskfile \u5fc5\u987b\u4f7f\u7528\u4e0e\u4e3b Taskfile \u4f7f\u7528\u7684\u76f8\u540c\u89c4\u5219\u7248\u672c\u3002")),(0,l.kt)("h3",{id:"\u53ef\u9009-includes"},"\u53ef\u9009 includes"),(0,l.kt)("p",null,"\u5982\u679c\u5305\u542b\u6587\u4ef6\u4e22\u5931\uff0c\u6807\u8bb0\u4e3a\u53ef\u9009\u7684\u5305\u542b\u5c06\u5141\u8bb8 task \u7ee7\u7eed\u6b63\u5e38\u6267\u884c\u3002"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n tests:\n taskfile: ./tests/Taskfile.yml\n optional: true\n\ntasks:\n greet:\n cmds:\n - echo \"This command can still be successfully executed if ./tests/Taskfile.yml does not exist\"\n")),(0,l.kt)("h3",{id:"\u5185\u90e8-includes"},"\u5185\u90e8 includes"),(0,l.kt)("p",null,"Includes marked as internal will set all the tasks of the included file to be internal as well (see the ",(0,l.kt)("a",{parentName:"p",href:"#internal-tasks"},"Internal tasks")," section below). This is useful when including utility tasks that are not intended to be used directly by the user."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n tests:\n taskfile: ./taskfiles/Utils.yml\n internal: true\n")),(0,l.kt)("h3",{id:"\u5305\u542b\u7684-taskfile-\u7684\u53d8\u91cf"},"\u5305\u542b\u7684 Taskfile \u7684\u53d8\u91cf"),(0,l.kt)("p",null,"\u60a8\u8fd8\u53ef\u4ee5\u5728\u5305\u542b Taskfile \u65f6\u6307\u5b9a\u53d8\u91cf\u3002 \u8fd9\u5bf9\u4e8e\u62e5\u6709\u53ef\u4ee5\u8c03\u6574\u751a\u81f3\u591a\u6b21\u5305\u542b\u7684\u53ef\u91cd\u7528 Taskfile \u53ef\u80fd\u5f88\u6709\u7528\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n backend:\n taskfile: ./taskfiles/Docker.yml\n vars:\n DOCKER_IMAGE: backend_image\n\n frontend:\n taskfile: ./taskfiles/Docker.yml\n vars:\n DOCKER_IMAGE: frontend_image\n")),(0,l.kt)("h3",{id:"\u547d\u540d\u7a7a\u95f4\u522b\u540d"},"\u547d\u540d\u7a7a\u95f4\u522b\u540d"),(0,l.kt)("p",null,"When including a Taskfile, you can give the namespace a list of ",(0,l.kt)("inlineCode",{parentName:"p"},"aliases"),". This works in the same way as ",(0,l.kt)("a",{parentName:"p",href:"#task-aliases"},"task aliases")," and can be used together to create shorter and easier-to-type commands."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n generate:\n taskfile: ./taskfiles/Generate.yml\n aliases: [gen]\n")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"Vars declared in the included Taskfile have preference over the variables in the including Taskfile! If you want a variable in an included Taskfile to be overridable, use the ",(0,l.kt)("a",{parentName:"p",href:"https://go-task.github.io/slim-sprig/defaults.html"},"default function"),": ",(0,l.kt)("inlineCode",{parentName:"p"},"MY_VAR: '{{.MY_VAR | default \"my-default-value\"}}'"),".")),(0,l.kt)("h2",{id:"\u5185\u90e8-tasks"},"\u5185\u90e8 tasks"),(0,l.kt)("p",null,"Internal tasks are tasks that cannot be called directly by the user. They will not appear in the output when running ",(0,l.kt)("inlineCode",{parentName:"p"},"task --list|--list-all"),". Other tasks may call internal tasks in the usual way. This is useful for creating reusable, function-like tasks that have no useful purpose on the command line."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build-image-1:\n cmds:\n - task: build-image\n vars:\n DOCKER_IMAGE: image-1\n\n build-image:\n internal: true\n cmds:\n - docker build -t {{.DOCKER_IMAGE}} .\n")),(0,l.kt)("h2",{id:"task-\u76ee\u5f55"},"Task \u76ee\u5f55"),(0,l.kt)("p",null,"By default, tasks will be executed in the directory where the Taskfile is located. But you can easily make the task run in another folder, informing ",(0,l.kt)("inlineCode",{parentName:"p"},"dir"),":"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n serve:\n dir: public/www\n cmds:\n # run http server\n - caddy\n")),(0,l.kt)("p",null,"\u5982\u679c\u8be5\u76ee\u5f55\u4e0d\u5b58\u5728\uff0c",(0,l.kt)("inlineCode",{parentName:"p"},"task")," \u4f1a\u521b\u5efa\u5b83\u3002"),(0,l.kt)("h2",{id:"task-\u4f9d\u8d56"},"Task \u4f9d\u8d56"),(0,l.kt)("blockquote",null,(0,l.kt)("p",{parentName:"blockquote"},"Dependencies run in parallel, so dependencies of a task should not depend one another. If you want to force tasks to run serially, take a look at the ",(0,l.kt)("a",{parentName:"p",href:"#calling-another-task"},"Calling Another Task")," section below.")),(0,l.kt)("p",null,"You may have tasks that depend on others. Just pointing them on ",(0,l.kt)("inlineCode",{parentName:"p"},"deps")," will make them run automatically before running the parent task:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n deps: [assets]\n cmds:\n - go build -v -i main.go\n\n assets:\n cmds:\n - esbuild --bundle --minify css/index.css > public/bundle.css\n")),(0,l.kt)("p",null,"In the above example, ",(0,l.kt)("inlineCode",{parentName:"p"},"assets")," will always run right before ",(0,l.kt)("inlineCode",{parentName:"p"},"build")," if you run ",(0,l.kt)("inlineCode",{parentName:"p"},"task build"),"."),(0,l.kt)("p",null,"\u4e00\u4e2a\u4efb\u52a1\u53ea\u80fd\u6709\u4f9d\u8d56\u5173\u7cfb\uff0c\u6ca1\u6709\u547d\u4ee4\u6765\u5c06\u4efb\u52a1\u7ec4\u5408\u5728\u4e00\u8d77\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n assets:\n deps: [js, css]\n\n js:\n cmds:\n - esbuild --bundle --minify js/index.js > public/bundle.js\n\n css:\n cmds:\n - esbuild --bundle --minify css/index.css > public/bundle.css\n")),(0,l.kt)("p",null,"\u5982\u679c\u6709\u591a\u4e2a\u4f9d\u8d56\u9879\uff0c\u5b83\u4eec\u603b\u662f\u5e76\u884c\u8fd0\u884c\u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u6027\u80fd\u3002"),(0,l.kt)("admonition",{type:"tip"},(0,l.kt)("p",{parentName:"admonition"},"You can also make the tasks given by the command line run in parallel by using the ",(0,l.kt)("inlineCode",{parentName:"p"},"--parallel")," flag (alias ",(0,l.kt)("inlineCode",{parentName:"p"},"-p"),"). Example: ",(0,l.kt)("inlineCode",{parentName:"p"},"task --parallel js css"),".")),(0,l.kt)("p",null,"\u5982\u679c\u4f60\u60f3\u5c06\u4fe1\u606f\u4f20\u9012\u7ed9\u4f9d\u8d56\u9879\uff0c\u4f60\u53ef\u4ee5\u50cf ",(0,l.kt)("a",{parentName:"p",href:"#%E8%B0%83%E7%94%A8%E5%8F%A6%E4%B8%80%E4%B8%AA-task"},"\u8c03\u7528\u53e6\u4e00\u4e2a\u4efb\u52a1")," \u4e00\u6837\u4ee5\u76f8\u540c\u7684\u65b9\u5f0f\u8fdb\u884c\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'3\'\n\ntasks:\n default:\n deps:\n - task: echo_sth\n vars: {TEXT: "before 1"}\n - task: echo_sth\n vars: {TEXT: "before 2"}\n cmds:\n - echo "after"\n\n echo_sth:\n cmds:\n - echo {{.TEXT}}\n')),(0,l.kt)("h2",{id:"\u5e73\u53f0\u7279\u5b9a\u7684-tasks-\u548c-cmds"},"\u5e73\u53f0\u7279\u5b9a\u7684 tasks \u548c cmds"),(0,l.kt)("p",null,"If you want to restrict the running of tasks to explicit platforms, this can be achieved using the ",(0,l.kt)("inlineCode",{parentName:"p"},"platforms:")," key. Tasks can be restricted to a specific OS, architecture or a combination of both. On a mismatch, the task or command will be skipped, and no error will be thrown."),(0,l.kt)("p",null,"The values allowed as OS or Arch are valid ",(0,l.kt)("inlineCode",{parentName:"p"},"GOOS")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"GOARCH")," values, as defined by the Go language ",(0,l.kt)("a",{parentName:"p",href:"https://github.com/golang/go/blob/master/src/go/build/syslist.go"},"here"),"."),(0,l.kt)("p",null,"The ",(0,l.kt)("inlineCode",{parentName:"p"},"build-windows")," task below will run only on Windows, and on any architecture:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build-windows:\n platforms: [windows]\n cmds:\n - echo 'Running command on Windows'\n")),(0,l.kt)("p",null,"This can be restricted to a specific architecture as follows:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build-windows-amd64:\n platforms: [windows/amd64]\n cmds:\n - echo 'Running command on Windows (amd64)'\n")),(0,l.kt)("p",null,"It is also possible to restrict the task to specific architectures:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build-amd64:\n platforms: [amd64]\n cmds:\n - echo 'Running command on amd64'\n")),(0,l.kt)("p",null,"Multiple platforms can be specified as follows:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n platforms: [windows/amd64, darwin]\n cmds:\n - echo 'Running command on Windows (amd64) and macOS'\n")),(0,l.kt)("p",null,"Individual commands can also be restricted to specific platforms:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n cmds:\n - cmd: echo 'Running command on Windows (amd64) and macOS'\n platforms: [windows/amd64, darwin]\n - cmd: echo 'Running on all platforms'\n")),(0,l.kt)("h2",{id:"\u8c03\u7528\u53e6\u4e00\u4e2a-task"},"\u8c03\u7528\u53e6\u4e00\u4e2a task"),(0,l.kt)("p",null,"\u5f53\u4e00\u4e2a task \u6709\u5f88\u591a\u4f9d\u8d56\u65f6\uff0c\u5b83\u4eec\u662f\u5e76\u53d1\u6267\u884c\u7684\u3002 \u8fd9\u901a\u5e38\u4f1a\u5bfc\u81f4\u66f4\u5feb\u7684\u6784\u5efa\u7ba1\u9053\u3002 \u4f46\u662f\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4e32\u884c\u8c03\u7528\u5176\u4ed6 task\u3002 \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'3\'\n\ntasks:\n main-task:\n cmds:\n - task: task-to-be-called\n - task: another-task\n - echo "Both done"\n\n task-to-be-called:\n cmds:\n - echo "Task to be called"\n\n another-task:\n cmds:\n - echo "Another task"\n')),(0,l.kt)("p",null,"\u5728\u88ab\u8c03\u7528 task \u4e2d\u8986\u76d6\u53d8\u91cf\u5c31\u50cf\u901a\u77e5 ",(0,l.kt)("inlineCode",{parentName:"p"},"vars")," \u5c5e\u6027\u4e00\u6837\u7b80\u5355\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'3\'\n\ntasks:\n greet:\n vars:\n RECIPIENT: \'{{default "World" .RECIPIENT}}\'\n cmds:\n - echo "Hello, {{.RECIPIENT}}!"\n\n greet-pessimistically:\n cmds:\n - task: greet\n vars: {RECIPIENT: "Cruel World"}\n')),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"deps")," \u4e5f\u652f\u6301\u4e0a\u8ff0\u8bed\u6cd5\u3002"),(0,l.kt)("admonition",{type:"tip"},(0,l.kt)("p",{parentName:"admonition"},"NOTE: If you want to call a task declared in the root Taskfile from within an ",(0,l.kt)("a",{parentName:"p",href:"#including-other-taskfiles"},"included Taskfile"),", add a leading ",(0,l.kt)("inlineCode",{parentName:"p"},":")," like this: ",(0,l.kt)("inlineCode",{parentName:"p"},"task: :task-name"),".")),(0,l.kt)("h2",{id:"\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u5de5\u4f5c"},"\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u5de5\u4f5c"),(0,l.kt)("h3",{id:"\u901a\u8fc7\u6307\u7eb9\u8bc6\u522b\u672c\u5730\u751f\u6210\u7684\u6587\u4ef6\u53ca\u5176\u6765\u6e90"},"\u901a\u8fc7\u6307\u7eb9\u8bc6\u522b\u672c\u5730\u751f\u6210\u7684\u6587\u4ef6\u53ca\u5176\u6765\u6e90"),(0,l.kt)("p",null,"\u5982\u679c\u4e00\u4e2a task \u751f\u6210\u4e86\u4e00\u4e9b\u4e1c\u897f\uff0c\u4f60\u53ef\u4ee5\u901a\u77e5 task \u6e90\u548c\u751f\u6210\u7684\u6587\u4ef6\uff0c\u8fd9\u6837 task \u5c31\u4f1a\u5728\u4e0d\u9700\u8981\u7684\u65f6\u5019\u963b\u6b62\u8fd0\u884c\u5b83\u4eec\u3002"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n deps: [js, css]\n cmds:\n - go build -v -i main.go\n\n js:\n cmds:\n - esbuild --bundle --minify js/index.js > public/bundle.js\n sources:\n - src/js/**/*.js\n generates:\n - public/bundle.js\n\n css:\n cmds:\n - esbuild --bundle --minify css/index.css > public/bundle.css\n sources:\n - src/css/**/*.css\n generates:\n - public/bundle.css\n")),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"sources")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"generates")," can be files or file patterns. When given, 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 ",(0,l.kt)("inlineCode",{parentName:"p"},'Task "js" is up to date'),"."),(0,l.kt)("p",null,"If you prefer this check to be made by the modification timestamp of the files, instead of its checksum (content), just set the ",(0,l.kt)("inlineCode",{parentName:"p"},"method")," property to ",(0,l.kt)("inlineCode",{parentName:"p"},"timestamp"),"."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n cmds:\n - go build .\n sources:\n - ./*.go\n generates:\n - app{{exeExt}}\n method: timestamp\n")),(0,l.kt)("p",null,"In situations where you need more flexibility the ",(0,l.kt)("inlineCode",{parentName:"p"},"status")," keyword can be used. You can even combine the two. See the documentation for ",(0,l.kt)("a",{parentName:"p",href:"#using-programmatic-checks-to-indicate-a-task-is-up-to-date"},"status")," for an example."),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"By default, task stores checksums on a local ",(0,l.kt)("inlineCode",{parentName:"p"},".task")," directory in the project's directory. Most of the time, you'll want to have this directory on ",(0,l.kt)("inlineCode",{parentName:"p"},".gitignore")," (or equivalent) so it isn't committed. (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)."),(0,l.kt)("p",{parentName:"admonition"},"If you want these files to be stored in another directory, you can set a ",(0,l.kt)("inlineCode",{parentName:"p"},"TASK_TEMP_DIR")," environment variable in your machine. It can contain a relative path like ",(0,l.kt)("inlineCode",{parentName:"p"},"tmp/task")," that will be interpreted as relative to the project directory, or an absolute or home path like ",(0,l.kt)("inlineCode",{parentName:"p"},"/tmp/.task")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"~/.task")," (subdirectories will be created for each project)."),(0,l.kt)("pre",{parentName:"admonition"},(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"export TASK_TEMP_DIR='~/.task'\n"))),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"Each task has only one checksum stored for its ",(0,l.kt)("inlineCode",{parentName:"p"},"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."),(0,l.kt)("p",{parentName:"admonition"},"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.")),(0,l.kt)("admonition",{type:"tip"},(0,l.kt)("p",{parentName:"admonition"},"The method ",(0,l.kt)("inlineCode",{parentName:"p"},"none")," skips any validation and always run the task.")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"For the ",(0,l.kt)("inlineCode",{parentName:"p"},"checksum")," (default) or ",(0,l.kt)("inlineCode",{parentName:"p"},"timestamp")," method to work, it is only necessary to inform the source files. When the ",(0,l.kt)("inlineCode",{parentName:"p"},"timestamp")," method is used, the last time of the running the task is considered as a generate.")),(0,l.kt)("h3",{id:"\u4f7f\u7528\u7a0b\u5e8f\u68c0\u67e5\u6765\u8868\u793a\u4efb\u52a1\u662f\u6700\u65b0\u7684"},"\u4f7f\u7528\u7a0b\u5e8f\u68c0\u67e5\u6765\u8868\u793a\u4efb\u52a1\u662f\u6700\u65b0\u7684\u3002"),(0,l.kt)("p",null,"Alternatively, you can inform a sequence of tests as ",(0,l.kt)("inlineCode",{parentName:"p"},"status"),". If no error is returned (exit status 0), the task is considered up-to-date:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n generate-files:\n cmds:\n - mkdir directory\n - touch directory/file1.txt\n - touch directory/file2.txt\n # test existence of files\n status:\n - test -d directory\n - test -f directory/file1.txt\n - test -f directory/file2.txt\n")),(0,l.kt)("p",null,"Normally, you would use ",(0,l.kt)("inlineCode",{parentName:"p"},"sources")," in combination with ",(0,l.kt)("inlineCode",{parentName:"p"},"generates")," - but for tasks that generate remote artifacts (Docker images, deploys, CD releases) the checksum source and timestamps require either access to the artifact or for an out-of-band refresh of the ",(0,l.kt)("inlineCode",{parentName:"p"},".checksum")," fingerprint file."),(0,l.kt)("p",null,"Two special variables ",(0,l.kt)("inlineCode",{parentName:"p"},"{{.CHECKSUM}}")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"{{.TIMESTAMP}}")," are available for interpolation within ",(0,l.kt)("inlineCode",{parentName:"p"},"status")," commands, depending on the method assigned to fingerprint the sources. Only ",(0,l.kt)("inlineCode",{parentName:"p"},"source")," globs are fingerprinted."),(0,l.kt)("p",null,"Note that the ",(0,l.kt)("inlineCode",{parentName:"p"},"{{.TIMESTAMP}}"),' variable is a "live" Go ',(0,l.kt)("inlineCode",{parentName:"p"},"time.Time")," struct, and can be formatted using any of the methods that ",(0,l.kt)("inlineCode",{parentName:"p"},"time.Time")," responds to."),(0,l.kt)("p",null,"\u6709\u5173\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 ",(0,l.kt)("a",{parentName:"p",href:"https://golang.org/pkg/time/"},"Go Time \u6587\u6863"),"\u3002"),(0,l.kt)("p",null,"You can use ",(0,l.kt)("inlineCode",{parentName:"p"},"--force")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"-f")," if you want to force a task to run even when up-to-date."),(0,l.kt)("p",null,"Also, ",(0,l.kt)("inlineCode",{parentName:"p"},"task --status [tasks]...")," will exit with a non-zero exit code if any of the tasks are not up-to-date."),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"status")," can be combined with the ",(0,l.kt)("a",{parentName:"p",href:"#by-fingerprinting-locally-generated-files-and-their-sources"},"fingerprinting")," to have a task run if either the the source/generated artifacts changes, or the programmatic check fails:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:prod:\n desc: Build for production usage.\n cmds:\n - composer install\n # Run this task if source files changes.\n sources:\n - composer.json\n - composer.lock\n generates:\n - ./vendor/composer/installed.json\n - ./vendor/autoload.php\n # But also run the task if the last build was not a production build.\n status:\n - grep -q '\"dev\": false' ./vendor/composer/installed.json\n")),(0,l.kt)("h3",{id:"\u4f7f\u7528\u7a0b\u5e8f\u68c0\u67e5\u53d6\u6d88\u4efb\u52a1\u53ca\u5176\u4f9d\u8d56\u9879\u7684\u6267\u884c"},"\u4f7f\u7528\u7a0b\u5e8f\u68c0\u67e5\u53d6\u6d88\u4efb\u52a1\u53ca\u5176\u4f9d\u8d56\u9879\u7684\u6267\u884c"),(0,l.kt)("p",null,"In addition to ",(0,l.kt)("inlineCode",{parentName:"p"},"status")," checks, ",(0,l.kt)("inlineCode",{parentName:"p"},"preconditions")," checks are the logical inverse of ",(0,l.kt)("inlineCode",{parentName:"p"},"status")," checks. That is, if you need a certain set of conditions to be ",(0,l.kt)("em",{parentName:"p"},"true")," you can use the ",(0,l.kt)("inlineCode",{parentName:"p"},"preconditions")," stanza. ",(0,l.kt)("inlineCode",{parentName:"p"},"preconditions")," are similar to ",(0,l.kt)("inlineCode",{parentName:"p"},"status")," lines, except they support ",(0,l.kt)("inlineCode",{parentName:"p"},"sh")," expansion, and they SHOULD all return 0."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'3\'\n\ntasks:\n generate-files:\n cmds:\n - mkdir directory\n - touch directory/file1.txt\n - touch directory/file2.txt\n # test existence of files\n preconditions:\n - test -f .env\n - sh: "[ 1 = 0 ]"\n msg: "One doesn\'t equal Zero, Halting"\n')),(0,l.kt)("p",null,"Preconditions can set specific failure messages that can tell a user what steps to take using the ",(0,l.kt)("inlineCode",{parentName:"p"},"msg")," field."),(0,l.kt)("p",null,"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 ",(0,l.kt)("inlineCode",{parentName:"p"},"--force")," is given."),(0,l.kt)("p",null,"Unlike ",(0,l.kt)("inlineCode",{parentName:"p"},"status"),", which will skip a task if it is up to date and continue executing tasks that depend on it, a ",(0,l.kt)("inlineCode",{parentName:"p"},"precondition")," will fail a task, along with any other tasks that depend on it."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'3\'\n\ntasks:\n task-will-fail:\n preconditions:\n - sh: "exit 1"\n\n task-will-also-fail:\n deps:\n - task-will-fail\n\n task-will-still-fail:\n cmds:\n - task: task-will-fail\n - echo "I will not run"\n')),(0,l.kt)("h3",{id:"\u5728\u4efb\u52a1\u8fd0\u884c\u65f6\u9650\u5236"},"\u5728\u4efb\u52a1\u8fd0\u884c\u65f6\u9650\u5236"),(0,l.kt)("p",null,"If a task executed by multiple ",(0,l.kt)("inlineCode",{parentName:"p"},"cmds")," or multiple ",(0,l.kt)("inlineCode",{parentName:"p"},"deps")," you can control when it is executed using ",(0,l.kt)("inlineCode",{parentName:"p"},"run"),". ",(0,l.kt)("inlineCode",{parentName:"p"},"run")," can also be set at the root of the Taskfile to change the behavior of all the tasks unless explicitly overridden."),(0,l.kt)("p",null,"Supported values for ",(0,l.kt)("inlineCode",{parentName:"p"},"run"),":"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"always")," (default) always attempt to invoke the task regardless of the number of previous executions"),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"once")," only invoke this task once regardless of the number of references"),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"when_changed")," only invokes the task once for each unique set of variables passed into the task")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n default:\n cmds:\n - task: generate-file\n vars: { CONTENT: '1' }\n - task: generate-file\n vars: { CONTENT: '2' }\n - task: generate-file\n vars: { CONTENT: '2' }\n\n generate-file:\n run: when_changed\n deps:\n - install-deps\n cmds:\n - echo {{.CONTENT}}\n\n install-deps:\n run: once\n cmds:\n - sleep 5 # long operation like installing packages\n")),(0,l.kt)("h2",{id:"\u53d8\u91cf"},"\u53d8\u91cf"),(0,l.kt)("p",null,"When doing interpolation of variables, Task will look for the below. They are listed below in order of importance (i.e. most important first):"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"Variables declared in the task definition"),(0,l.kt)("li",{parentName:"ul"},"Variables given while calling a task from another (See ",(0,l.kt)("a",{parentName:"li",href:"#calling-another-task"},"Calling another task")," above)"),(0,l.kt)("li",{parentName:"ul"},"Variables of the ",(0,l.kt)("a",{parentName:"li",href:"#including-other-taskfiles"},"included Taskfile")," (when the task is included)"),(0,l.kt)("li",{parentName:"ul"},"Variables of the ",(0,l.kt)("a",{parentName:"li",href:"#vars-of-included-taskfiles"},"inclusion of the Taskfile")," (when the task is included)"),(0,l.kt)("li",{parentName:"ul"},"Global variables (those declared in the ",(0,l.kt)("inlineCode",{parentName:"li"},"vars:")," option in the Taskfile)"),(0,l.kt)("li",{parentName:"ul"},"Environment variables")),(0,l.kt)("p",null,"Example of sending parameters with environment variables:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"$ TASK_VARIABLE=a-value task do-something\n")),(0,l.kt)("admonition",{type:"tip"},(0,l.kt)("p",{parentName:"admonition"},"A special variable ",(0,l.kt)("inlineCode",{parentName:"p"},".TASK")," is always available containing the task name.")),(0,l.kt)("p",null,"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."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},'$ task write-file FILE=file.txt "CONTENT=Hello, World!" print "MESSAGE=All done!"\n')),(0,l.kt)("p",null,"Example of locally declared vars:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n print-var:\n cmds:\n - echo \"{{.VAR}}\"\n vars:\n VAR: Hello!\n")),(0,l.kt)("p",null,"Example of global vars in a ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskfile.yml"),":"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nvars:\n GREETING: Hello from Taskfile!\n\ntasks:\n greet:\n cmds:\n - echo \"{{.GREETING}}\"\n")),(0,l.kt)("h3",{id:"\u52a8\u6001\u53d8\u91cf"},"\u52a8\u6001\u53d8\u91cf"),(0,l.kt)("p",null,"The below syntax (",(0,l.kt)("inlineCode",{parentName:"p"},"sh:")," prop in a variable) is considered a dynamic variable. The value will be treated as a command and the output assigned. If there are one or more trailing newlines, the last newline will be trimmed."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n cmds:\n - go build -ldflags=\"-X main.Version={{.GIT_COMMIT}}\" main.go\n vars:\n GIT_COMMIT:\n sh: git log -n 1 --format=%h\n")),(0,l.kt)("p",null,"This works for all types of variables."),(0,l.kt)("h2",{id:"\u5c06-cli-\u53c2\u6570\u8f6c\u53d1\u5230-cmds"},"\u5c06 CLI \u53c2\u6570\u8f6c\u53d1\u5230 cmds"),(0,l.kt)("p",null,"If ",(0,l.kt)("inlineCode",{parentName:"p"},"--")," is given in the CLI, all following parameters are added to a special ",(0,l.kt)("inlineCode",{parentName:"p"},".CLI_ARGS")," variable. This is useful to forward arguments to another command."),(0,l.kt)("p",null,"The below example will run ",(0,l.kt)("inlineCode",{parentName:"p"},"yarn install"),"."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"$ task yarn -- install\n")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n yarn:\n cmds:\n - yarn {{.CLI_ARGS}}\n")),(0,l.kt)("h2",{id:"\u4f7f\u7528-defer-\u505a-task-\u6e05\u7406"},"\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"h2"},"defer")," \u505a task \u6e05\u7406"),(0,l.kt)("p",null,"With the ",(0,l.kt)("inlineCode",{parentName:"p"},"defer")," keyword, it's possible to schedule cleanup to be run once the task finishes. The difference with just putting it as the last command is that this command will run even when the task fails."),(0,l.kt)("p",null,"In the example below, ",(0,l.kt)("inlineCode",{parentName:"p"},"rm -rf tmpdir/")," will run even if the third command fails:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n default:\n cmds:\n - mkdir -p tmpdir/\n - defer: rm -rf tmpdir/\n - echo 'Do work on tmpdir/'\n")),(0,l.kt)("p",null,"If you want to move the cleanup command into another task, that is possible as well:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n default:\n cmds:\n - mkdir -p tmpdir/\n - defer: { task: cleanup }\n - echo 'Do work on tmpdir/'\n\n cleanup: rm -rf tmpdir/\n")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"Due to the nature of how the ",(0,l.kt)("a",{parentName:"p",href:"https://go.dev/tour/flowcontrol/13"},"Go's own ",(0,l.kt)("inlineCode",{parentName:"a"},"defer")," work"),", the deferred commands are executed in the reverse order if you schedule multiple of them.")),(0,l.kt)("h2",{id:"go-\u7684\u6a21\u677f\u5f15\u64ce"},"Go \u7684\u6a21\u677f\u5f15\u64ce"),(0,l.kt)("p",null,"Task parse commands as ",(0,l.kt)("a",{parentName:"p",href:"https://golang.org/pkg/text/template/"},"Go's template engine")," before executing them. Variables are accessible through dot syntax (",(0,l.kt)("inlineCode",{parentName:"p"},".VARNAME"),")."),(0,l.kt)("p",null,"All functions by the Go's ",(0,l.kt)("a",{parentName:"p",href:"https://go-task.github.io/slim-sprig/"},"slim-sprig lib")," are available. The following example gets the current date in a given format:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n print-date:\n cmds:\n - echo {{now | date \"2006-01-02\"}}\n")),(0,l.kt)("p",null,"Task also adds the following functions:"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"OS"),': Returns the operating system. Possible values are "windows", "linux", "darwin" (macOS) and "freebsd".'),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"ARCH"),': return the architecture Task was compiled to: "386", "amd64", "arm" or "s390x".'),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"splitLines"),": Splits Unix (\\n) and Windows (\\r\\n) styled newlines."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"catLines"),": Replaces Unix (\\n) and Windows (\\r\\n) styled newlines with a space."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"toSlash"),": Does nothing on Unix, but on Windows converts a string from ",(0,l.kt)("inlineCode",{parentName:"li"},"\\")," path format to ",(0,l.kt)("inlineCode",{parentName:"li"},"/"),"."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"fromSlash"),": Opposite of ",(0,l.kt)("inlineCode",{parentName:"li"},"toSlash"),". Does nothing on Unix, but on Windows converts a string from ",(0,l.kt)("inlineCode",{parentName:"li"},"/")," path format to ",(0,l.kt)("inlineCode",{parentName:"li"},"\\"),"."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"exeExt"),": Returns the right executable extension for the current OS (",(0,l.kt)("inlineCode",{parentName:"li"},'".exe"')," for Windows, ",(0,l.kt)("inlineCode",{parentName:"li"},'""')," for others)."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"shellQuote"),": Quotes a string to make it safe for use in shell scripts. Task uses ",(0,l.kt)("a",{parentName:"li",href:"https://pkg.go.dev/mvdan.cc/sh/v3@v3.4.0/syntax#Quote"},"this Go function")," for this. The Bash dialect is assumed."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"splitArgs"),": Splits a string as if it were a command's arguments. Task uses ",(0,l.kt)("a",{parentName:"li",href:"https://pkg.go.dev/mvdan.cc/sh/v3@v3.4.0/shell#Fields"},"this Go function"))),(0,l.kt)("p",null,"Example:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n print-os:\n cmds:\n - echo '{{OS}} {{ARCH}}'\n - echo '{{if eq OS \"windows\"}}windows-command{{else}}unix-command{{end}}'\n # This will be path/to/file on Unix but path\\to\\file on Windows\n - echo '{{fromSlash \"path/to/file\"}}'\n enumerated-file:\n vars:\n CONTENT: |\n foo\n bar\n cmds:\n - |\n cat << EOF > output.txt\n {{range $i, $line := .CONTENT | splitLines -}}\n {{printf \"%3d\" $i}}: {{$line}}\n {{end}}EOF\n")),(0,l.kt)("h2",{id:"\u5e2e\u52a9"},"\u5e2e\u52a9"),(0,l.kt)("p",null,"Running ",(0,l.kt)("inlineCode",{parentName:"p"},"task --list")," (or ",(0,l.kt)("inlineCode",{parentName:"p"},"task -l"),") lists all tasks with a description. The following Taskfile:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n desc: Build the go binary.\n cmds:\n - go build -v -i main.go\n\n test:\n desc: Run all the go tests.\n cmds:\n - go test -race ./...\n\n js:\n cmds:\n - esbuild --bundle --minify js/index.js > public/bundle.js\n\n css:\n cmds:\n - esbuild --bundle --minify css/index.css > public/bundle.css\n")),(0,l.kt)("p",null,"would print the following output:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"* build: Build the go binary.\n* test: Run all the go tests.\n")),(0,l.kt)("p",null,"If you want to see all tasks, there's a ",(0,l.kt)("inlineCode",{parentName:"p"},"--list-all")," (alias ",(0,l.kt)("inlineCode",{parentName:"p"},"-a"),") flag as well."),(0,l.kt)("h2",{id:"\u663e\u793a\u4efb\u52a1\u6458\u8981"},"\u663e\u793a\u4efb\u52a1\u6458\u8981"),(0,l.kt)("p",null,"Running ",(0,l.kt)("inlineCode",{parentName:"p"},"task --summary task-name")," will show a summary of a task. The following Taskfile:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n release:\n deps: [build]\n summary: |\n Release your project to github\n\n It will build your project before starting the release.\n Please make sure that you have set GITHUB_TOKEN before starting.\n cmds:\n - your-release-tool\n\n build:\n cmds:\n - your-build-tool\n")),(0,l.kt)("p",null,"with running ",(0,l.kt)("inlineCode",{parentName:"p"},"task --summary release")," would print the following output:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre"},"task: release\n\nRelease your project to github\n\nIt will build your project before starting the release.\nPlease make sure that you have set GITHUB_TOKEN before starting.\n\ndependencies:\n - build\n\ncommands:\n - your-release-tool\n")),(0,l.kt)("p",null,"If a summary is missing, the description will be printed. If the task does not have a summary or a description, a warning is printed."),(0,l.kt)("p",null,"Please note: ",(0,l.kt)("em",{parentName:"p"},"showing the summary will not execute the command"),"."),(0,l.kt)("h2",{id:"task-\u522b\u540d"},"Task \u522b\u540d"),(0,l.kt)("p",null,"Aliases are alternative names for tasks. They can be used to make it easier and quicker to run tasks with long or hard-to-type names. You can use them on the command line, when ",(0,l.kt)("a",{parentName:"p",href:"#calling-another-task"},"calling sub-tasks")," in your Taskfile and when ",(0,l.kt)("a",{parentName:"p",href:"#including-other-taskfiles"},"including tasks")," with aliases from another Taskfile. They can also be used together with ",(0,l.kt)("a",{parentName:"p",href:"#namespace-aliases"},"namespace aliases"),"."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n generate:\n aliases: [gen]\n cmds:\n - task: gen-mocks\n\n generate-mocks:\n aliases: [gen-mocks]\n cmds:\n - echo \"generating...\"\n")),(0,l.kt)("h2",{id:"\u91cd\u5199-task-\u540d\u79f0"},"\u91cd\u5199 Task \u540d\u79f0"),(0,l.kt)("p",null,"Sometimes you may want to override the task name printed on the summary, up-to-date messages to STDOUT, etc. In this case, you can just set ",(0,l.kt)("inlineCode",{parentName:"p"},"label:"),", which can also be interpolated with variables:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n default:\n - task: print\n vars:\n MESSAGE: hello\n - task: print\n vars:\n MESSAGE: world\n\n print:\n label: 'print-{{.MESSAGE}}'\n cmds:\n - echo \"{{.MESSAGE}}\"\n")),(0,l.kt)("h2",{id:"\u9759\u9ed8\u6a21\u5f0f"},"\u9759\u9ed8\u6a21\u5f0f"),(0,l.kt)("p",null,"Silent mode disables the echoing of commands before Task runs it. For the following Taskfile:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n echo:\n cmds:\n - echo \"Print something\"\n")),(0,l.kt)("p",null,"Normally this will be printed:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-sh"},'echo "Print something"\nPrint something\n')),(0,l.kt)("p",null,"With silent mode on, the below will be printed instead:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-sh"},"Print something\n")),(0,l.kt)("p",null,"There are four ways to enable silent mode:"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"At command level:")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n echo:\n cmds:\n - cmd: echo \"Print something\"\n silent: true\n")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"At task level:")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n echo:\n cmds:\n - echo \"Print something\"\n silent: true\n")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"Globally at Taskfile level:")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nsilent: true\n\ntasks:\n echo:\n cmds:\n - echo \"Print something\"\n")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"Or globally with ",(0,l.kt)("inlineCode",{parentName:"li"},"--silent")," or ",(0,l.kt)("inlineCode",{parentName:"li"},"-s")," flag")),(0,l.kt)("p",null,"If you want to suppress STDOUT instead, just redirect a command to ",(0,l.kt)("inlineCode",{parentName:"p"},"/dev/null"),":"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n echo:\n cmds:\n - echo \"This will print nothing\" > /dev/null\n")),(0,l.kt)("h2",{id:"\u8bd5\u8fd0\u884c\u6a21\u5f0f"},"\u8bd5\u8fd0\u884c\u6a21\u5f0f"),(0,l.kt)("p",null,"Dry run mode (",(0,l.kt)("inlineCode",{parentName:"p"},"--dry"),") compiles and steps through each task, printing the commands that would be run without executing them. This is useful for debugging your Taskfiles."),(0,l.kt)("h2",{id:"\u5ffd\u7565\u9519\u8bef"},"\u5ffd\u7565\u9519\u8bef"),(0,l.kt)("p",null,"You have the option to ignore errors during command execution. Given the following Taskfile:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n echo:\n cmds:\n - exit 1\n - echo \"Hello World\"\n")),(0,l.kt)("p",null,"Task will abort the execution after running ",(0,l.kt)("inlineCode",{parentName:"p"},"exit 1")," because the status code ",(0,l.kt)("inlineCode",{parentName:"p"},"1")," stands for ",(0,l.kt)("inlineCode",{parentName:"p"},"EXIT_FAILURE"),". However, it is possible to continue with execution using ",(0,l.kt)("inlineCode",{parentName:"p"},"ignore_error"),":"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n echo:\n cmds:\n - cmd: exit 1\n ignore_error: true\n - echo \"Hello World\"\n")),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"ignore_error")," can also be set for a task, which means errors will be suppressed for all commands. Nevertheless, keep in mind that this option will not propagate to other tasks called either by ",(0,l.kt)("inlineCode",{parentName:"p"},"deps")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"cmds"),"!"),(0,l.kt)("h2",{id:"\u8f93\u51fa\u8bed\u6cd5"},"\u8f93\u51fa\u8bed\u6cd5"),(0,l.kt)("p",null,"By default, Task just redirects the STDOUT and STDERR of the running commands to the shell in real-time. This is good for having live feedback for logging printed by commands, but the output can become messy if you have multiple commands running simultaneously and printing lots of stuff."),(0,l.kt)("p",null,"To make this more customizable, there are currently three different output options you can choose:"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"interleaved")," (default)"),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"group")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"prefixed"))),(0,l.kt)("p",null,"To choose another one, just set it to root in the Taskfile:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\noutput: 'group'\n\ntasks:\n # ...\n")),(0,l.kt)("p",null,"The ",(0,l.kt)("inlineCode",{parentName:"p"},"group")," output will print the entire output of a command once after it finishes, so you will not have live feedback for commands that take a long time to run."),(0,l.kt)("p",null,"When using the ",(0,l.kt)("inlineCode",{parentName:"p"},"group")," output, you can optionally provide a templated message to print at the start and end of the group. This can be useful for instructing CI systems to group all of the output for a given task, such as with ",(0,l.kt)("a",{parentName:"p",href:"https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#grouping-log-lines"},"GitHub Actions' ",(0,l.kt)("inlineCode",{parentName:"a"},"::group::")," command")," or ",(0,l.kt)("a",{parentName:"p",href:"https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?expand=1&view=azure-devops&tabs=bash#formatting-commands"},"Azure Pipelines"),"."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\noutput:\n group:\n begin: '::group::{{.TASK}}'\n end: '::endgroup::'\n\ntasks:\n default:\n cmds:\n - echo 'Hello, World!'\n silent: true\n")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"$ task default\n::group::default\nHello, World!\n::endgroup::\n")),(0,l.kt)("p",null,"When using the ",(0,l.kt)("inlineCode",{parentName:"p"},"group")," output, you may swallow the output of the executed command on standard output and standard error if it does not fail (zero exit code)."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nsilent: true\n\noutput:\n group:\n error_only: true\n\ntasks:\n passes: echo 'output-of-passes'\n errors: echo 'output-of-errors' && exit 1\n")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},'$ task passes\n$ task errors\noutput-of-errors\ntask: Failed to run task "errors": exit status 1\n')),(0,l.kt)("p",null,"The ",(0,l.kt)("inlineCode",{parentName:"p"},"prefix")," output will prefix every line printed by a command with ",(0,l.kt)("inlineCode",{parentName:"p"},"[task-name]")," as the prefix, but you can customize the prefix for a command with the ",(0,l.kt)("inlineCode",{parentName:"p"},"prefix:")," attribute:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'3\'\n\noutput: prefixed\n\ntasks:\n default:\n deps:\n - task: print\n vars: {TEXT: foo}\n - task: print\n vars: {TEXT: bar}\n - task: print\n vars: {TEXT: baz}\n\n print:\n cmds:\n - echo "{{.TEXT}}"\n prefix: "print-{{.TEXT}}"\n silent: true\n')),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"$ task default\n[print-foo] foo\n[print-bar] bar\n[print-baz] baz\n")),(0,l.kt)("admonition",{type:"tip"},(0,l.kt)("p",{parentName:"admonition"},"The ",(0,l.kt)("inlineCode",{parentName:"p"},"output")," option can also be specified by the ",(0,l.kt)("inlineCode",{parentName:"p"},"--output")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"-o")," flags.")),(0,l.kt)("h2",{id:"\u4ea4\u4e92\u5f0f-cli-\u5e94\u7528"},"\u4ea4\u4e92\u5f0f CLI \u5e94\u7528"),(0,l.kt)("p",null,"When running interactive CLI applications inside Task they can sometimes behave weirdly, especially when the ",(0,l.kt)("a",{parentName:"p",href:"#output-syntax"},"output mode")," is set to something other than ",(0,l.kt)("inlineCode",{parentName:"p"},"interleaved")," (the default), or when interactive apps are run in parallel with other tasks."),(0,l.kt)("p",null,"The ",(0,l.kt)("inlineCode",{parentName:"p"},"interactive: true")," tells Task this is an interactive application and Task will try to optimize for it:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n default:\n cmds:\n - vim my-file.txt\n interactive: true\n")),(0,l.kt)("p",null,"If you still have problems running an interactive app through Task, please open an issue about it."),(0,l.kt)("h2",{id:"\u77ed-task-\u8bed\u6cd5"},"\u77ed Task \u8bed\u6cd5"),(0,l.kt)("p",null,"Starting on Task v3, you can now write tasks with a shorter syntax if they have the default settings (e.g. no custom ",(0,l.kt)("inlineCode",{parentName:"p"},"env:"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"vars:"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"desc:"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"silent:")," , etc):"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build: go build -v -o ./app{{exeExt}} .\n\n run:\n - task: build\n - ./app{{exeExt}} -h localhost -p 8080\n")),(0,l.kt)("h2",{id:"set-\u548c-shopt"},(0,l.kt)("inlineCode",{parentName:"h2"},"set")," \u548c ",(0,l.kt)("inlineCode",{parentName:"h2"},"shopt")),(0,l.kt)("p",null,"It's possible to specify options to the ",(0,l.kt)("a",{parentName:"p",href:"https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html"},(0,l.kt)("inlineCode",{parentName:"a"},"set"))," and ",(0,l.kt)("a",{parentName:"p",href:"https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html"},(0,l.kt)("inlineCode",{parentName:"a"},"shopt"))," builtins. This can be added at global, task or command level."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nset: [pipefail]\nshopt: [globstar]\n\ntasks:\n # `globstar` required for double star globs to work\n default: echo **/*.go\n")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"Keep in mind that not all options are available in the ",(0,l.kt)("a",{parentName:"p",href:"https://github.com/mvdan/sh"},"shell interpreter library")," that Task uses.")),(0,l.kt)("h2",{id:"\u89c2\u5bdf\u4efb\u52a1"},"\u89c2\u5bdf\u4efb\u52a1"),(0,l.kt)("p",null,"With the flags ",(0,l.kt)("inlineCode",{parentName:"p"},"--watch")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"-w")," task will watch for file changes and run the task again. This requires the ",(0,l.kt)("inlineCode",{parentName:"p"},"sources")," attribute to be given, so task knows which files to watch."),(0,l.kt)("p",null,"The default watch interval is 5 seconds, but it's possible to change it by either setting ",(0,l.kt)("inlineCode",{parentName:"p"},"interval: '500ms'")," in the root of the Taskfile passing it as an argument like ",(0,l.kt)("inlineCode",{parentName:"p"},"--interval=500ms"),"."))}k.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/zh-Hans/assets/js/01713e21.d102d208.js b/zh-Hans/assets/js/01713e21.d102d208.js new file mode 100644 index 00000000..6f924b4f --- /dev/null +++ b/zh-Hans/assets/js/01713e21.d102d208.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktaskfile_dev=self.webpackChunktaskfile_dev||[]).push([[701],{3905:function(e,n,t){t.d(n,{Zo:function(){return d},kt:function(){return c}});var a=t(7294);function l(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function s(e){for(var n=1;n=0||(l[t]=e[t]);return l}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(l[t]=e[t])}return l}var o=a.createContext({}),p=function(e){var n=a.useContext(o),t=n;return e&&(t="function"==typeof e?e(n):s(s({},n),e)),t},d=function(e){var n=p(e.components);return a.createElement(o.Provider,{value:n},e.children)},k="mdxType",m={inlineCode:"code",wrapper:function(e){var n=e.children;return a.createElement(a.Fragment,{},n)}},u=a.forwardRef((function(e,n){var t=e.components,l=e.mdxType,i=e.originalType,o=e.parentName,d=r(e,["components","mdxType","originalType","parentName"]),k=p(t),u=l,c=k["".concat(o,".").concat(u)]||k[u]||m[u]||i;return t?a.createElement(c,s(s({ref:n},d),{},{components:t})):a.createElement(c,s({ref:n},d))}));function c(e,n){var t=arguments,l=n&&n.mdxType;if("string"==typeof e||l){var i=t.length,s=new Array(i);s[0]=u;var r={};for(var o in n)hasOwnProperty.call(n,o)&&(r[o]=n[o]);r.originalType=e,r[k]="string"==typeof e?e:l,s[1]=r;for(var p=2;pdefer \u505a task \u6e05\u7406",id:"\u4f7f\u7528-defer-\u505a-task-\u6e05\u7406",level:2},{value:"Go \u7684\u6a21\u677f\u5f15\u64ce",id:"go-\u7684\u6a21\u677f\u5f15\u64ce",level:2},{value:"\u5e2e\u52a9",id:"\u5e2e\u52a9",level:2},{value:"\u663e\u793a\u4efb\u52a1\u6458\u8981",id:"\u663e\u793a\u4efb\u52a1\u6458\u8981",level:2},{value:"Task \u522b\u540d",id:"task-\u522b\u540d",level:2},{value:"\u8986\u76d6 Task \u540d\u79f0",id:"\u8986\u76d6-task-\u540d\u79f0",level:2},{value:"\u9759\u9ed8\u6a21\u5f0f",id:"\u9759\u9ed8\u6a21\u5f0f",level:2},{value:"\u8bd5\u8fd0\u884c\u6a21\u5f0f",id:"\u8bd5\u8fd0\u884c\u6a21\u5f0f",level:2},{value:"\u5ffd\u7565\u9519\u8bef",id:"\u5ffd\u7565\u9519\u8bef",level:2},{value:"\u8f93\u51fa\u8bed\u6cd5",id:"\u8f93\u51fa\u8bed\u6cd5",level:2},{value:"\u4ea4\u4e92\u5f0f CLI \u5e94\u7528",id:"\u4ea4\u4e92\u5f0f-cli-\u5e94\u7528",level:2},{value:"\u77ed Task \u8bed\u6cd5",id:"\u77ed-task-\u8bed\u6cd5",level:2},{value:"set \u548c shopt",id:"set-\u548c-shopt",level:2},{value:"\u89c2\u5bdf\u4efb\u52a1",id:"\u89c2\u5bdf\u4efb\u52a1",level:2}],d={toc:p};function k(e){let{components:n,...t}=e;return(0,l.kt)("wrapper",(0,a.Z)({},d,t,{components:n,mdxType:"MDXLayout"}),(0,l.kt)("h1",{id:"\u4f7f\u7528\u6307\u5357"},"\u4f7f\u7528\u6307\u5357"),(0,l.kt)("h2",{id:"\u5feb\u901f\u5165\u95e8"},"\u5feb\u901f\u5165\u95e8"),(0,l.kt)("p",null,"\u5728\u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskfile.yml")," \u7684\u6587\u4ef6\u3002 ",(0,l.kt)("inlineCode",{parentName:"p"},"cmds")," \u5c5e\u6027\u5e94\u5305\u542b task \u7684\u547d\u4ee4\u3002 \u4e0b\u9762\u7684\u793a\u4f8b\u5141\u8bb8\u7f16\u8bd1 Go \u5e94\u7528\u7a0b\u5e8f\u5e76\u4f7f\u7528 ",(0,l.kt)("a",{parentName:"p",href:"https://esbuild.github.io/"},"esbuild")," \u5c06\u591a\u4e2a CSS \u6587\u4ef6\u5408\u5e76\u5e76\u7f29\u5c0f\u4e3a\u4e00\u4e2a\u6587\u4ef6\u3002"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n cmds:\n - go build -v -i main.go\n\n assets:\n cmds:\n - esbuild --bundle --minify css/index.css > public/bundle.css\n")),(0,l.kt)("p",null,"\u8fd0\u884c task \u5c31\u8fd9\u6837\u7b80\u5355\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"task assets build\n")),(0,l.kt)("p",null,"Task \u4f7f\u7528 ",(0,l.kt)("a",{parentName:"p",href:"https://mvdan.cc/sh/"},"mvdan.cc/sh"),"\uff0c\u4e00\u4e2a\u539f\u751f\u7684 Go sh \u89e3\u91ca\u5668\u3002 \u56e0\u6b64\uff0c\u60a8\u53ef\u4ee5\u7f16\u5199 sh/bash \u547d\u4ee4\uff0c\u5b83\u751a\u81f3\u53ef\u4ee5\u5728 Windows \u4e0a\u8fd0\u884c\uff0c\u800c ",(0,l.kt)("inlineCode",{parentName:"p"},"sh")," \u6216 ",(0,l.kt)("inlineCode",{parentName:"p"},"bash")," \u901a\u5e38\u4e0d\u53ef\u7528\u3002 \u8bf7\u8bb0\u4f4f\uff0c\u4efb\u4f55\u88ab\u8c03\u7528\u7684\u53ef\u6267\u884c\u6587\u4ef6\u90fd\u5fc5\u987b\u5728\u64cd\u4f5c\u7cfb\u7edf\u6216 PATH \u4e2d\u53ef\u7528\u3002"),(0,l.kt)("p",null,'\u5982\u679c\u4e0d\u4f20 task \u7684\u540d\u5b57\uff0c\u9ed8\u8ba4\u4f1a\u8c03\u7528 "default"\u3002'),(0,l.kt)("h2",{id:"\u652f\u6301\u7684\u6587\u4ef6\u540d\u79f0"},"\u652f\u6301\u7684\u6587\u4ef6\u540d\u79f0"),(0,l.kt)("p",null,"Task \u4f1a\u6309\u4ee5\u4e0b\u987a\u5e8f\u67e5\u627e\u914d\u7f6e\u6587\u4ef6:"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"Taskfile.yml"),(0,l.kt)("li",{parentName:"ul"},"Taskfile.yaml"),(0,l.kt)("li",{parentName:"ul"},"Taskfile.dist.yml"),(0,l.kt)("li",{parentName:"ul"},"Taskfile.dist.yaml")),(0,l.kt)("p",null,"\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},".dist")," \u53d8\u4f53\u7684\u76ee\u7684\u662f\u5141\u8bb8\u9879\u76ee\u6709\u4e00\u4e2a\u63d0\u4ea4\u7248\u672c (",(0,l.kt)("inlineCode",{parentName:"p"},".dist"),")\uff0c\u540c\u65f6\u4ecd\u7136\u5141\u8bb8\u4e2a\u4eba\u7528\u6237\u901a\u8fc7\u6dfb\u52a0\u989d\u5916\u7684 ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskfile.yml"),"\uff08\u5c06\u5728 ",(0,l.kt)("inlineCode",{parentName:"p"},".gitignore")," \u4e0a\uff09\u6765\u8986\u76d6 Taskfile\u3002"),(0,l.kt)("h3",{id:"\u4ece\u5b50\u76ee\u5f55\u8fd0\u884c-taskfile"},"\u4ece\u5b50\u76ee\u5f55\u8fd0\u884c Taskfile"),(0,l.kt)("p",null,"\u5982\u679c\u5728\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u4e2d\u627e\u4e0d\u5230 Taskfile\uff0c\u5b83\u5c06\u6cbf\u7740\u6587\u4ef6\u6811\u5411\u4e0a\u67e5\u627e\uff0c\u76f4\u5230\u627e\u5230\u4e00\u4e2a\uff08\u7c7b\u4f3c\u4e8e ",(0,l.kt)("inlineCode",{parentName:"p"},"git")," \u7684\u5de5\u4f5c\u65b9\u5f0f\uff09\u3002 \u5f53\u4ece\u8fd9\u6837\u7684\u5b50\u76ee\u5f55\u8fd0\u884c Task \u65f6\uff0c\u5b83\u7684\u884c\u4e3a\u5c31\u50cf\u4ece\u5305\u542b Taskfile \u7684\u76ee\u5f55\u8fd0\u884c\u5b83\u4e00\u6837\u3002"),(0,l.kt)("p",null,"\u60a8\u53ef\u4ee5\u5c06\u6b64\u529f\u80fd\u4e0e\u7279\u6b8a\u7684 ",(0,l.kt)("inlineCode",{parentName:"p"},"{{.USER_WORKING_DIR}}")," \u53d8\u91cf\u4e00\u8d77\u4f7f\u7528\u6765\u521b\u5efa\u4e00\u4e9b\u975e\u5e38\u6709\u7528\u7684\u53ef\u91cd\u7528 task\u3002 \u4f8b\u5982\uff0c\u5982\u679c\u4f60\u6709\u4e00\u4e2a\u5305\u542b\u6bcf\u4e2a\u5fae\u670d\u52a1\u76ee\u5f55\u7684 monorepo\uff0c\u4f60\u53ef\u4ee5 ",(0,l.kt)("inlineCode",{parentName:"p"},"cd")," \u8fdb\u5165\u4e00\u4e2a\u5fae\u670d\u52a1\u76ee\u5f55\u5e76\u8fd0\u884c\u4e00\u4e2a task \u547d\u4ee4\u6765\u542f\u52a8\u5b83\uff0c\u800c\u4e0d\u5fc5\u521b\u5efa\u591a\u4e2a task \u6216\u5177\u6709\u76f8\u540c\u5185\u5bb9\u7684 Taskfile\u3002 \u4f8b\u5982\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n up:\n dir: '{{.USER_WORKING_DIR}}'\n preconditions:\n - test -f docker-compose.yml\n cmds:\n - docker-compose up -d\n")),(0,l.kt)("p",null,"\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u8fd0\u884c ",(0,l.kt)("inlineCode",{parentName:"p"},"cd ")," \u548c ",(0,l.kt)("inlineCode",{parentName:"p"},"task up"),"\uff0c\u53ea\u8981 ",(0,l.kt)("inlineCode",{parentName:"p"},"")," \u76ee\u5f55\u5305\u542b ",(0,l.kt)("inlineCode",{parentName:"p"},"docker-compose.yml"),"\uff0c\u5c31\u4f1a\u542f\u52a8 Docker Compose\u3002"),(0,l.kt)("h3",{id:"\u8fd0\u884c\u5168\u5c40-taskfile"},"\u8fd0\u884c\u5168\u5c40 Taskfile"),(0,l.kt)("p",null,"\u5982\u679c\u60a8\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},"--global"),"\uff08\u522b\u540d ",(0,l.kt)("inlineCode",{parentName:"p"},"-g"),"\uff09\u6807\u5fd7\u8c03\u7528 Task\uff0c\u5b83\u5c06\u67e5\u627e\u60a8\u7684 home \u76ee\u5f55\u800c\u4e0d\u662f\u60a8\u7684\u5de5\u4f5c\u76ee\u5f55\u3002 \u7b80\u800c\u8a00\u4e4b\uff0cTask \u5c06\u5728 ",(0,l.kt)("inlineCode",{parentName:"p"},"$HOME/Taskfile.yml")," \u6216 ",(0,l.kt)("inlineCode",{parentName:"p"},"$HOME/Taskfile.yaml")," \u8def\u5f84\u4e0a\u5bfb\u627e Taskfile\u3002"),(0,l.kt)("p",null,"\u8fd9\u5bf9\u4e8e\u60a8\u53ef\u4ee5\u5728\u7cfb\u7edf\u7684\u4efb\u4f55\u5730\u65b9\u8fd0\u884c\u7684\u81ea\u52a8\u5316\u5f88\u6709\u7528\uff01"),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"When running your global Taskfile with ",(0,l.kt)("inlineCode",{parentName:"p"},"-g"),", tasks will run on ",(0,l.kt)("inlineCode",{parentName:"p"},"$HOME")," by default, and not on your working directory!"),(0,l.kt)("p",{parentName:"admonition"},"As mentioned in the previous section, the ",(0,l.kt)("inlineCode",{parentName:"p"},"{{.USER_WORKING_DIR}}")," special variable can be very handy here to run stuff on the directory you're calling ",(0,l.kt)("inlineCode",{parentName:"p"},"task -g")," from."),(0,l.kt)("pre",{parentName:"admonition"},(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n from-home:\n cmds:\n - pwd\n\n from-working-directory:\n dir: '{{.USER_WORKING_DIR}}'\n cmds:\n - pwd\n"))),(0,l.kt)("h2",{id:"\u73af\u5883\u53d8\u91cf"},"\u73af\u5883\u53d8\u91cf"),(0,l.kt)("h3",{id:"task"},"Task"),(0,l.kt)("p",null,"\u4f60\u53ef\u4ee5\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},"env")," \u7ed9\u6bcf\u4e2a task \u8bbe\u7f6e\u81ea\u5b9a\u4e49\u73af\u5883\u53d8\u91cf:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n greet:\n cmds:\n - echo $GREETING\n env:\n GREETING: Hey, there!\n")),(0,l.kt)("p",null,"\u6b64\u5916\uff0c\u60a8\u53ef\u4ee5\u8bbe\u7f6e\u53ef\u7528\u4e8e\u6240\u6709 task \u7684\u5168\u5c40\u73af\u5883\u53d8\u91cf\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nenv:\n GREETING: Hey, there!\n\ntasks:\n greet:\n cmds:\n - echo $GREETING\n")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},(0,l.kt)("inlineCode",{parentName:"p"},"env")," \u652f\u6301\u6269\u5c55\u548c\u68c0\u7d22 shell \u547d\u4ee4\u7684\u8f93\u51fa\uff0c\u5c31\u50cf\u53d8\u91cf\u4e00\u6837\uff0c\u5982\u60a8\u5728 ",(0,l.kt)("a",{parentName:"p",href:"#%E5%8F%98%E9%87%8F"},"\u53d8\u91cf")," \u90e8\u5206\u4e2d\u770b\u5230\u7684\u90a3\u6837\u3002")),(0,l.kt)("h3",{id:"env-\u6587\u4ef6"},".env \u6587\u4ef6"),(0,l.kt)("p",null,"\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},"dotenv:")," \u8bbe\u7f6e\u8981\u6c42 tasks \u5305\u542b ",(0,l.kt)("inlineCode",{parentName:"p"},".env")," \u4e4b\u7c7b\u7684\u6587\u4ef6"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash",metastring:'title=".env"',title:'".env"'},"KEYNAME=VALUE\n")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash",metastring:'title="testing/.env"',title:'"testing/.env"'},"ENDPOINT=testing.com\n")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml",metastring:'title="Taskfile.yml"',title:'"Taskfile.yml"'},"version: '3'\n\nenv:\n ENV: testing\n\ndotenv: ['.env', '{{.ENV}}/.env.', '{{.HOME}}/.env']\n\ntasks:\n greet:\n cmds:\n - echo \"Using $KEYNAME and endpoint $ENDPOINT\"\n")),(0,l.kt)("p",null,"\u4e5f\u53ef\u4ee5\u5728 task \u7ea7\u522b\u6307\u5b9a .env \u6587\u4ef6\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nenv:\n ENV: testing\n\ntasks:\n greet:\n dotenv: ['.env', '{{.ENV}}/.env.', '{{.HOME}}/.env']\n cmds:\n - echo \"Using $KEYNAME and endpoint $ENDPOINT\"\n")),(0,l.kt)("p",null,"\u5728 task \u7ea7\u522b\u660e\u786e\u6307\u5b9a\u7684\u73af\u5883\u53d8\u91cf\u5c06\u8986\u76d6\u70b9\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684\u53d8\u91cf\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nenv:\n ENV: testing\n\ntasks:\n greet:\n dotenv: ['.env', '{{.ENV}}/.env.', '{{.HOME}}/.env']\n env:\n KEYNAME: DIFFERENT_VALUE\n cmds:\n - echo \"Using $KEYNAME and endpoint $ENDPOINT\"\n")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"\u8bf7\u6ce8\u610f\uff0c\u60a8\u76ee\u524d\u65e0\u6cd5\u5728\u5305\u542b\u7684 Taskfile \u4e2d\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},"dotenv")," \u952e\u3002")),(0,l.kt)("h2",{id:"\u5305\u542b\u5176\u4ed6-taskfile"},"\u5305\u542b\u5176\u4ed6 Taskfile"),(0,l.kt)("p",null,"\u5982\u679c\u8981\u5728\u4e0d\u540c\u9879\u76ee\uff08Taskfile\uff09\u4e4b\u95f4\u5171\u4eab\u4efb\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528\u5bfc\u5165\u673a\u5236\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},"includes")," \u5173\u952e\u5b57\u5305\u542b\u5176\u4ed6\u4efb\u52a1\u6587\u4ef6\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n docs: ./documentation # will look for ./documentation/Taskfile.yml\n docker: ./DockerTasks.yml\n")),(0,l.kt)("p",null,"The tasks described in the given Taskfiles will be available with the informed namespace. So, you'd call ",(0,l.kt)("inlineCode",{parentName:"p"},"task docs:serve")," to run the ",(0,l.kt)("inlineCode",{parentName:"p"},"serve")," task from ",(0,l.kt)("inlineCode",{parentName:"p"},"documentation/Taskfile.yml")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"task docker:build")," to run the ",(0,l.kt)("inlineCode",{parentName:"p"},"build")," task from the ",(0,l.kt)("inlineCode",{parentName:"p"},"DockerTasks.yml")," file."),(0,l.kt)("p",null,"\u76f8\u5bf9\u8def\u5f84\u662f\u76f8\u5bf9\u4e8e\u5305\u542b\u5305\u542b Taskfile \u7684\u76ee\u5f55\u89e3\u6790\u7684\u3002"),(0,l.kt)("h3",{id:"\u64cd\u4f5c\u7cfb\u7edf\u7279\u5b9a-taskfile"},"\u64cd\u4f5c\u7cfb\u7edf\u7279\u5b9a Taskfile"),(0,l.kt)("p",null,"With ",(0,l.kt)("inlineCode",{parentName:"p"},"version: '2'"),", task automatically includes any ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskfile_{{OS}}.yml")," if it exists (for example: ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskfile_windows.yml"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskfile_linux.yml")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"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:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n build: ./Taskfile_{{OS}}.yml\n")),(0,l.kt)("h3",{id:"\u5305\u542b-taskfile-\u7684\u76ee\u5f55"},"\u5305\u542b Taskfile \u7684\u76ee\u5f55"),(0,l.kt)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5305\u542b\u7684 Taskfile \u7684 task \u5728\u5f53\u524d\u76ee\u5f55\u4e2d\u8fd0\u884c\uff0c\u5373\u4f7f Taskfile \u5728\u53e6\u4e00\u4e2a\u76ee\u5f55\u4e2d\uff0c\u4f46\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u66ff\u4ee3\u8bed\u6cd5\u5f3a\u5236\u5176 task \u5728\u53e6\u4e00\u4e2a\u76ee\u5f55\u4e2d\u8fd0\u884c\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n docs:\n taskfile: ./docs/Taskfile.yml\n dir: ./docs\n")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"\u5305\u542b\u7684 Taskfile \u5fc5\u987b\u4f7f\u7528\u4e0e\u4e3b Taskfile \u4f7f\u7528\u7684\u76f8\u540c\u89c4\u5219\u7248\u672c\u3002")),(0,l.kt)("h3",{id:"\u53ef\u9009-includes"},"\u53ef\u9009 includes"),(0,l.kt)("p",null,"\u5982\u679c\u5305\u542b\u6587\u4ef6\u4e22\u5931\uff0c\u6807\u8bb0\u4e3a\u53ef\u9009\u7684\u5305\u542b\u5c06\u5141\u8bb8 task \u7ee7\u7eed\u6b63\u5e38\u6267\u884c\u3002"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n tests:\n taskfile: ./tests/Taskfile.yml\n optional: true\n\ntasks:\n greet:\n cmds:\n - echo \"This command can still be successfully executed if ./tests/Taskfile.yml does not exist\"\n")),(0,l.kt)("h3",{id:"\u5185\u90e8-includes"},"\u5185\u90e8 includes"),(0,l.kt)("p",null,"Includes marked as internal will set all the tasks of the included file to be internal as well (see the ",(0,l.kt)("a",{parentName:"p",href:"#internal-tasks"},"Internal tasks")," section below). This is useful when including utility tasks that are not intended to be used directly by the user."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n tests:\n taskfile: ./taskfiles/Utils.yml\n internal: true\n")),(0,l.kt)("h3",{id:"\u5305\u542b\u7684-taskfile-\u7684\u53d8\u91cf"},"\u5305\u542b\u7684 Taskfile \u7684\u53d8\u91cf"),(0,l.kt)("p",null,"\u60a8\u8fd8\u53ef\u4ee5\u5728\u5305\u542b Taskfile \u65f6\u6307\u5b9a\u53d8\u91cf\u3002 \u8fd9\u5bf9\u4e8e\u62e5\u6709\u53ef\u4ee5\u8c03\u6574\u751a\u81f3\u591a\u6b21\u5305\u542b\u7684\u53ef\u91cd\u7528 Taskfile \u53ef\u80fd\u5f88\u6709\u7528\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n backend:\n taskfile: ./taskfiles/Docker.yml\n vars:\n DOCKER_IMAGE: backend_image\n\n frontend:\n taskfile: ./taskfiles/Docker.yml\n vars:\n DOCKER_IMAGE: frontend_image\n")),(0,l.kt)("h3",{id:"\u547d\u540d\u7a7a\u95f4\u522b\u540d"},"\u547d\u540d\u7a7a\u95f4\u522b\u540d"),(0,l.kt)("p",null,"\u5305\u542b Taskfile \u65f6\uff0c\u60a8\u53ef\u4ee5\u4e3a\u547d\u540d\u7a7a\u95f4\u63d0\u4f9b\u4e00\u4e2a ",(0,l.kt)("inlineCode",{parentName:"p"},"aliases")," \u5217\u8868\u3002 \u8fd9\u4e0e ",(0,l.kt)("a",{parentName:"p",href:"#task-%E5%88%AB%E5%90%8D"},"task \u522b\u540d")," \u7684\u5de5\u4f5c\u65b9\u5f0f\u76f8\u540c\uff0c\u53ef\u4ee5\u4e00\u8d77\u4f7f\u7528\u6765\u521b\u5efa\u66f4\u77ed\u4e14\u66f4\u6613\u4e8e\u952e\u5165\u7684\u547d\u4ee4\u3002"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nincludes:\n generate:\n taskfile: ./taskfiles/Generate.yml\n aliases: [gen]\n")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"Vars declared in the included Taskfile have preference over the variables in the including Taskfile! If you want a variable in an included Taskfile to be overridable, use the ",(0,l.kt)("a",{parentName:"p",href:"https://go-task.github.io/slim-sprig/defaults.html"},"default function"),": ",(0,l.kt)("inlineCode",{parentName:"p"},"MY_VAR: '{{.MY_VAR | default \"my-default-value\"}}'"),".")),(0,l.kt)("h2",{id:"\u5185\u90e8-tasks"},"\u5185\u90e8 tasks"),(0,l.kt)("p",null,"Internal tasks are tasks that cannot be called directly by the user. They will not appear in the output when running ",(0,l.kt)("inlineCode",{parentName:"p"},"task --list|--list-all"),". Other tasks may call internal tasks in the usual way. This is useful for creating reusable, function-like tasks that have no useful purpose on the command line."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build-image-1:\n cmds:\n - task: build-image\n vars:\n DOCKER_IMAGE: image-1\n\n build-image:\n internal: true\n cmds:\n - docker build -t {{.DOCKER_IMAGE}} .\n")),(0,l.kt)("h2",{id:"task-\u76ee\u5f55"},"Task \u76ee\u5f55"),(0,l.kt)("p",null,"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0ctasks \u5c06\u5728 Taskfile \u6240\u5728\u7684\u76ee\u5f55\u4e2d\u6267\u884c\u3002 \u4f46\u662f\u60a8\u53ef\u4ee5\u8f7b\u677e\u5730\u8ba9 task \u5728\u53e6\u4e00\u4e2a\u76ee\u5f55\u4e2d\u8fd0\u884c\uff0c\u6307\u5b9a ",(0,l.kt)("inlineCode",{parentName:"p"},"dir"),"\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n serve:\n dir: public/www\n cmds:\n # run http server\n - caddy\n")),(0,l.kt)("p",null,"\u5982\u679c\u8be5\u76ee\u5f55\u4e0d\u5b58\u5728\uff0c",(0,l.kt)("inlineCode",{parentName:"p"},"task")," \u4f1a\u521b\u5efa\u5b83\u3002"),(0,l.kt)("h2",{id:"task-\u4f9d\u8d56"},"Task \u4f9d\u8d56"),(0,l.kt)("blockquote",null,(0,l.kt)("p",{parentName:"blockquote"},"\u4f9d\u8d56\u9879\u5e76\u884c\u8fd0\u884c\uff0c\u56e0\u6b64\u4e00\u9879 task \u7684\u4f9d\u8d56\u9879\u4e0d\u5e94\u76f8\u4e92\u4f9d\u8d56\u3002 \u5982\u679c\u60a8\u60f3\u5f3a\u5236\u4efb\u52a1\u987a\u5e8f\u8fd0\u884c\uff0c\u8bf7\u67e5\u770b\u4e0b\u9762\u7684 ",(0,l.kt)("a",{parentName:"p",href:"#%E8%B0%83%E7%94%A8%E5%8F%A6%E4%B8%80%E4%B8%AA-task"},"\u8c03\u7528\u53e6\u4e00\u4e2a task")," \u90e8\u5206\u3002")),(0,l.kt)("p",null,"\u60a8\u53ef\u80fd\u6709\u4f9d\u8d56\u4e8e\u5176\u5b83\u7684 task\u3002 \u5c06\u5b83\u4eec\u6307\u5411 ",(0,l.kt)("inlineCode",{parentName:"p"},"deps")," \u5c06\u4f7f\u5b83\u4eec\u5728\u8fd0\u884c\u7236 task \u4e4b\u524d\u81ea\u52a8\u8fd0\u884c\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n deps: [assets]\n cmds:\n - go build -v -i main.go\n\n assets:\n cmds:\n - esbuild --bundle --minify css/index.css > public/bundle.css\n")),(0,l.kt)("p",null,"\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u5982\u679c\u60a8\u8fd0\u884c ",(0,l.kt)("inlineCode",{parentName:"p"},"task build"),"\uff0c",(0,l.kt)("inlineCode",{parentName:"p"},"assets")," \u5c06\u59cb\u7ec8\u5728 ",(0,l.kt)("inlineCode",{parentName:"p"},"build")," \u4e4b\u524d\u8fd0\u884c\u3002"),(0,l.kt)("p",null,"\u4e00\u4e2a task \u53ea\u80fd\u6709\u4f9d\u8d56\u5173\u7cfb\uff0c\u6ca1\u6709\u547d\u4ee4\u6765\u5c06 task \u7ec4\u5408\u5728\u4e00\u8d77\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n assets:\n deps: [js, css]\n\n js:\n cmds:\n - esbuild --bundle --minify js/index.js > public/bundle.js\n\n css:\n cmds:\n - esbuild --bundle --minify css/index.css > public/bundle.css\n")),(0,l.kt)("p",null,"\u5982\u679c\u6709\u591a\u4e2a\u4f9d\u8d56\u9879\uff0c\u5b83\u4eec\u603b\u662f\u5e76\u884c\u8fd0\u884c\u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u6027\u80fd\u3002"),(0,l.kt)("admonition",{type:"tip"},(0,l.kt)("p",{parentName:"admonition"},"\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},"--parallel")," \u6807\u5fd7\uff08\u522b\u540d ",(0,l.kt)("inlineCode",{parentName:"p"},"-p"),"\uff09\u4f7f\u547d\u4ee4\u884c\u7ed9\u51fa\u7684 task \u5e76\u884c\u8fd0\u884c\u3002 \u4f8b\u5982: ",(0,l.kt)("inlineCode",{parentName:"p"},"task --parallel js css"),"\u3002")),(0,l.kt)("p",null,"\u5982\u679c\u4f60\u60f3\u5c06\u4fe1\u606f\u4f20\u9012\u7ed9\u4f9d\u8d56\u9879\uff0c\u4f60\u53ef\u4ee5\u50cf ",(0,l.kt)("a",{parentName:"p",href:"#%E8%B0%83%E7%94%A8%E5%8F%A6%E4%B8%80%E4%B8%AA-task"},"\u8c03\u7528\u53e6\u4e00\u4e2a task")," \u4e00\u6837\u4ee5\u76f8\u540c\u7684\u65b9\u5f0f\u8fdb\u884c\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'3\'\n\ntasks:\n default:\n deps:\n - task: echo_sth\n vars: {TEXT: "before 1"}\n - task: echo_sth\n vars: {TEXT: "before 2"}\n cmds:\n - echo "after"\n\n echo_sth:\n cmds:\n - echo {{.TEXT}}\n')),(0,l.kt)("h2",{id:"\u5e73\u53f0\u7279\u5b9a\u7684-tasks-\u548c-cmds"},"\u5e73\u53f0\u7279\u5b9a\u7684 tasks \u548c cmds"),(0,l.kt)("p",null,"\u5982\u679c\u60a8\u60f3\u5c06 task \u7684\u8fd0\u884c\u9650\u5236\u5728\u660e\u786e\u7684\u5e73\u53f0\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},"platforms:")," \u952e\u6765\u5b9e\u73b0\u3002 Task \u53ef\u4ee5\u9650\u5236\u5728\u7279\u5b9a\u7684\u64cd\u4f5c\u7cfb\u7edf\u3001\u67b6\u6784\u6216\u4e24\u8005\u7684\u7ec4\u5408\u4e2d\u3002 \u5982\u679c\u4e0d\u5339\u914d\uff0c\u4efb\u52a1\u6216\u547d\u4ee4\u5c06\u88ab\u8df3\u8fc7\uff0c\u5e76\u4e14\u4e0d\u4f1a\u629b\u51fa\u4efb\u4f55\u9519\u8bef\u3002"),(0,l.kt)("p",null,"\u5141\u8bb8\u4f5c\u4e3a OS \u6216 Arch \u7684\u503c\u662f\u6709\u6548\u7684 ",(0,l.kt)("inlineCode",{parentName:"p"},"GOOS")," \u548c ",(0,l.kt)("inlineCode",{parentName:"p"},"GOARCH")," \u503c\uff0c\u6b63\u5982 ",(0,l.kt)("a",{parentName:"p",href:"https://github.com/golang/go/blob/master/src/go/build/syslist.go"},"\u6b64\u5904")," \u7684 Go \u8bed\u8a00\u6240\u5b9a\u4e49\u7684\u90a3\u6837\u3002"),(0,l.kt)("p",null,"\u4e0b\u9762\u7684 ",(0,l.kt)("inlineCode",{parentName:"p"},"build-windows")," task \u5c06\u4ec5\u5728 Windows \u6240\u6709\u67b6\u6784\u4e0a\u8fd0\u884c\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build-windows:\n platforms: [windows]\n cmds:\n - echo 'Running command on Windows'\n")),(0,l.kt)("p",null,"\u8fd9\u53ef\u4ee5\u9650\u5236\u4e3a\u7279\u5b9a\u7684\u67b6\u6784\uff0c\u5982\u4e0b\u6240\u793a\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build-windows-amd64:\n platforms: [windows/amd64]\n cmds:\n - echo 'Running command on Windows (amd64)'\n")),(0,l.kt)("p",null,"\u4e5f\u53ef\u4ee5\u5c06 task \u9650\u5236\u5728\u7279\u5b9a\u7684\u67b6\u6784\u4e2d\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build-amd64:\n platforms: [amd64]\n cmds:\n - echo 'Running command on amd64'\n")),(0,l.kt)("p",null,"\u53ef\u4ee5\u6307\u5b9a\u591a\u4e2a\u5e73\u53f0\uff0c\u5982\u4e0b\u6240\u793a\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n platforms: [windows/amd64, darwin]\n cmds:\n - echo 'Running command on Windows (amd64) and macOS'\n")),(0,l.kt)("p",null,"\u4e2a\u522b\u547d\u4ee4\u4e5f\u53ef\u4ee5\u9650\u5236\u5728\u7279\u5b9a\u5e73\u53f0\u4e0a\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n cmds:\n - cmd: echo 'Running command on Windows (amd64) and macOS'\n platforms: [windows/amd64, darwin]\n - cmd: echo 'Running on all platforms'\n")),(0,l.kt)("h2",{id:"\u8c03\u7528\u53e6\u4e00\u4e2a-task"},"\u8c03\u7528\u53e6\u4e00\u4e2a task"),(0,l.kt)("p",null,"\u5f53\u4e00\u4e2a task \u6709\u5f88\u591a\u4f9d\u8d56\u65f6\uff0c\u5b83\u4eec\u662f\u5e76\u53d1\u6267\u884c\u7684\u3002 \u8fd9\u901a\u5e38\u4f1a\u5bfc\u81f4\u66f4\u5feb\u7684\u6784\u5efa\u7ba1\u9053\u3002 \u4f46\u662f\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4e32\u884c\u8c03\u7528\u5176\u4ed6 task\u3002 \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'3\'\n\ntasks:\n main-task:\n cmds:\n - task: task-to-be-called\n - task: another-task\n - echo "Both done"\n\n task-to-be-called:\n cmds:\n - echo "Task to be called"\n\n another-task:\n cmds:\n - echo "Another task"\n')),(0,l.kt)("p",null,"\u5728\u88ab\u8c03\u7528 task \u4e2d\u8986\u76d6\u53d8\u91cf\u5c31\u50cf\u901a\u77e5 ",(0,l.kt)("inlineCode",{parentName:"p"},"vars")," \u5c5e\u6027\u4e00\u6837\u7b80\u5355\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'3\'\n\ntasks:\n greet:\n vars:\n RECIPIENT: \'{{default "World" .RECIPIENT}}\'\n cmds:\n - echo "Hello, {{.RECIPIENT}}!"\n\n greet-pessimistically:\n cmds:\n - task: greet\n vars: {RECIPIENT: "Cruel World"}\n')),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"deps")," \u4e5f\u652f\u6301\u4e0a\u8ff0\u8bed\u6cd5\u3002"),(0,l.kt)("admonition",{type:"tip"},(0,l.kt)("p",{parentName:"admonition"},"\u6ce8\u610f\uff1a\u5982\u679c\u60a8\u60f3\u4ece ",(0,l.kt)("a",{parentName:"p",href:"#%E5%8C%85%E5%90%AB%E5%85%B6%E4%BB%96-taskfile"},"\u5305\u542b\u7684 Taskfile")," \u4e2d\u8c03\u7528\u5728\u6839 Taskfile \u4e2d\u58f0\u660e\u7684 task\uff0c\u8bf7\u50cf\u8fd9\u6837\u6dfb\u52a0 ",(0,l.kt)("inlineCode",{parentName:"p"},":")," \u524d\u7f00\uff1a",(0,l.kt)("inlineCode",{parentName:"p"},"task: :task-name"),"\u3002")),(0,l.kt)("h2",{id:"\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u5de5\u4f5c"},"\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u5de5\u4f5c"),(0,l.kt)("h3",{id:"\u901a\u8fc7\u6307\u7eb9\u8bc6\u522b\u672c\u5730\u751f\u6210\u7684\u6587\u4ef6\u53ca\u5176\u6765\u6e90"},"\u901a\u8fc7\u6307\u7eb9\u8bc6\u522b\u672c\u5730\u751f\u6210\u7684\u6587\u4ef6\u53ca\u5176\u6765\u6e90"),(0,l.kt)("p",null,"\u5982\u679c\u4e00\u4e2a task \u751f\u6210\u4e86\u4e00\u4e9b\u4e1c\u897f\uff0c\u4f60\u53ef\u4ee5\u901a\u77e5 task \u6e90\u548c\u751f\u6210\u7684\u6587\u4ef6\uff0c\u8fd9\u6837 task \u5c31\u4f1a\u5728\u4e0d\u9700\u8981\u7684\u65f6\u5019\u963b\u6b62\u8fd0\u884c\u5b83\u4eec\u3002"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n deps: [js, css]\n cmds:\n - go build -v -i main.go\n\n js:\n cmds:\n - esbuild --bundle --minify js/index.js > public/bundle.js\n sources:\n - src/js/**/*.js\n generates:\n - public/bundle.js\n\n css:\n cmds:\n - esbuild --bundle --minify css/index.css > public/bundle.css\n sources:\n - src/css/**/*.css\n generates:\n - public/bundle.css\n")),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"sources")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"generates")," can be files or file patterns. When given, 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 ",(0,l.kt)("inlineCode",{parentName:"p"},'Task "js" is up to date'),"."),(0,l.kt)("p",null,"\u5982\u679c\u60a8\u5e0c\u671b\u901a\u8fc7\u6587\u4ef6\u7684\u4fee\u6539 timestamp \u800c\u4e0d\u662f\u5176 checksum\uff08\u5185\u5bb9\uff09\u6765\u8fdb\u884c\u6b64\u68c0\u67e5\uff0c\u53ea\u9700\u5c06 ",(0,l.kt)("inlineCode",{parentName:"p"},"method")," \u5c5e\u6027\u8bbe\u7f6e\u4e3a ",(0,l.kt)("inlineCode",{parentName:"p"},"timestamp")," \u5373\u53ef\u3002"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n cmds:\n - go build .\n sources:\n - ./*.go\n generates:\n - app{{exeExt}}\n method: timestamp\n")),(0,l.kt)("p",null,"\u5728\u9700\u8981\u66f4\u5927\u7075\u6d3b\u6027\u7684\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},"status")," \u5173\u952e\u5b57\u3002 \u60a8\u751a\u81f3\u53ef\u4ee5\u5c06\u4e24\u8005\u7ed3\u5408\u8d77\u6765\u3002 \u6709\u5173\u793a\u4f8b\uff0c\u8bf7\u53c2\u9605 ",(0,l.kt)("a",{parentName:"p",href:"#%E4%BD%BF%E7%94%A8%E7%A8%8B%E5%BA%8F%E6%A3%80%E6%9F%A5%E6%9D%A5%E8%A1%A8%E7%A4%BA%E4%BB%BB%E5%8A%A1%E6%98%AF%E6%9C%80%E6%96%B0%E7%9A%84"},"\u72b6\u6001")," \u6587\u6863\u3002"),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"By default, task stores checksums on a local ",(0,l.kt)("inlineCode",{parentName:"p"},".task")," directory in the project's directory. Most of the time, you'll want to have this directory on ",(0,l.kt)("inlineCode",{parentName:"p"},".gitignore")," (or equivalent) so it isn't committed. (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)."),(0,l.kt)("p",{parentName:"admonition"},"If you want these files to be stored in another directory, you can set a ",(0,l.kt)("inlineCode",{parentName:"p"},"TASK_TEMP_DIR")," environment variable in your machine. It can contain a relative path like ",(0,l.kt)("inlineCode",{parentName:"p"},"tmp/task")," that will be interpreted as relative to the project directory, or an absolute or home path like ",(0,l.kt)("inlineCode",{parentName:"p"},"/tmp/.task")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"~/.task")," (subdirectories will be created for each project)."),(0,l.kt)("pre",{parentName:"admonition"},(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"export TASK_TEMP_DIR='~/.task'\n"))),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"Each task has only one checksum stored for its ",(0,l.kt)("inlineCode",{parentName:"p"},"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."),(0,l.kt)("p",{parentName:"admonition"},"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.")),(0,l.kt)("admonition",{type:"tip"},(0,l.kt)("p",{parentName:"admonition"},"\u5c06 method \u8bbe\u7f6e\u4e3a ",(0,l.kt)("inlineCode",{parentName:"p"},"none")," \u4f1a\u8df3\u8fc7\u4efb\u4f55\u9a8c\u8bc1\u5e76\u59cb\u7ec8\u8fd0\u884c\u4efb\u52a1\u3002")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"For the ",(0,l.kt)("inlineCode",{parentName:"p"},"checksum")," (default) or ",(0,l.kt)("inlineCode",{parentName:"p"},"timestamp")," method to work, it is only necessary to inform the source files. When the ",(0,l.kt)("inlineCode",{parentName:"p"},"timestamp")," method is used, the last time of the running the task is considered as a generate.")),(0,l.kt)("h3",{id:"\u4f7f\u7528\u7a0b\u5e8f\u68c0\u67e5\u6765\u8868\u793a\u4efb\u52a1\u662f\u6700\u65b0\u7684"},"\u4f7f\u7528\u7a0b\u5e8f\u68c0\u67e5\u6765\u8868\u793a\u4efb\u52a1\u662f\u6700\u65b0\u7684"),(0,l.kt)("p",null,"Alternatively, you can inform a sequence of tests as ",(0,l.kt)("inlineCode",{parentName:"p"},"status"),". If no error is returned (exit status 0), the task is considered up-to-date:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n generate-files:\n cmds:\n - mkdir directory\n - touch directory/file1.txt\n - touch directory/file2.txt\n # test existence of files\n status:\n - test -d directory\n - test -f directory/file1.txt\n - test -f directory/file2.txt\n")),(0,l.kt)("p",null,"Normally, you would use ",(0,l.kt)("inlineCode",{parentName:"p"},"sources")," in combination with ",(0,l.kt)("inlineCode",{parentName:"p"},"generates")," - but for tasks that generate remote artifacts (Docker images, deploys, CD releases) the checksum source and timestamps require either access to the artifact or for an out-of-band refresh of the ",(0,l.kt)("inlineCode",{parentName:"p"},".checksum")," fingerprint file."),(0,l.kt)("p",null,"Two special variables ",(0,l.kt)("inlineCode",{parentName:"p"},"{{.CHECKSUM}}")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"{{.TIMESTAMP}}")," are available for interpolation within ",(0,l.kt)("inlineCode",{parentName:"p"},"status")," commands, depending on the method assigned to fingerprint the sources. Only ",(0,l.kt)("inlineCode",{parentName:"p"},"source")," globs are fingerprinted."),(0,l.kt)("p",null,"Note that the ",(0,l.kt)("inlineCode",{parentName:"p"},"{{.TIMESTAMP}}"),' variable is a "live" Go ',(0,l.kt)("inlineCode",{parentName:"p"},"time.Time")," struct, and can be formatted using any of the methods that ",(0,l.kt)("inlineCode",{parentName:"p"},"time.Time")," responds to."),(0,l.kt)("p",null,"\u6709\u5173\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 ",(0,l.kt)("a",{parentName:"p",href:"https://golang.org/pkg/time/"},"Go Time \u6587\u6863"),"\u3002"),(0,l.kt)("p",null,"\u5982\u679c\u4f60\u60f3\u5f3a\u5236\u4efb\u52a1\u8fd0\u884c\uff0c\u5373\u4f7f\u662f\u6700\u65b0\u7684\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"p"},"--force")," \u6216 ",(0,l.kt)("inlineCode",{parentName:"p"},"-f"),"\u3002"),(0,l.kt)("p",null,"Also, ",(0,l.kt)("inlineCode",{parentName:"p"},"task --status [tasks]...")," will exit with a non-zero exit code if any of the tasks are not up-to-date."),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"status")," can be combined with the ",(0,l.kt)("a",{parentName:"p",href:"#by-fingerprinting-locally-generated-files-and-their-sources"},"fingerprinting")," to have a task run if either the the source/generated artifacts changes, or the programmatic check fails:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:prod:\n desc: Build for production usage.\n cmds:\n - composer install\n # Run this task if source files changes.\n sources:\n - composer.json\n - composer.lock\n generates:\n - ./vendor/composer/installed.json\n - ./vendor/autoload.php\n # But also run the task if the last build was not a production build.\n status:\n - grep -q '\"dev\": false' ./vendor/composer/installed.json\n")),(0,l.kt)("h3",{id:"\u4f7f\u7528\u7a0b\u5e8f\u68c0\u67e5\u53d6\u6d88\u4efb\u52a1\u53ca\u5176\u4f9d\u8d56\u9879\u7684\u6267\u884c"},"\u4f7f\u7528\u7a0b\u5e8f\u68c0\u67e5\u53d6\u6d88\u4efb\u52a1\u53ca\u5176\u4f9d\u8d56\u9879\u7684\u6267\u884c"),(0,l.kt)("p",null,"In addition to ",(0,l.kt)("inlineCode",{parentName:"p"},"status")," checks, ",(0,l.kt)("inlineCode",{parentName:"p"},"preconditions")," checks are the logical inverse of ",(0,l.kt)("inlineCode",{parentName:"p"},"status")," checks. That is, if you need a certain set of conditions to be ",(0,l.kt)("em",{parentName:"p"},"true")," you can use the ",(0,l.kt)("inlineCode",{parentName:"p"},"preconditions")," stanza. ",(0,l.kt)("inlineCode",{parentName:"p"},"preconditions")," are similar to ",(0,l.kt)("inlineCode",{parentName:"p"},"status")," lines, except they support ",(0,l.kt)("inlineCode",{parentName:"p"},"sh")," expansion, and they SHOULD all return 0."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'3\'\n\ntasks:\n generate-files:\n cmds:\n - mkdir directory\n - touch directory/file1.txt\n - touch directory/file2.txt\n # test existence of files\n preconditions:\n - test -f .env\n - sh: "[ 1 = 0 ]"\n msg: "One doesn\'t equal Zero, Halting"\n')),(0,l.kt)("p",null,"Preconditions can set specific failure messages that can tell a user what steps to take using the ",(0,l.kt)("inlineCode",{parentName:"p"},"msg")," field."),(0,l.kt)("p",null,"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 ",(0,l.kt)("inlineCode",{parentName:"p"},"--force")," is given."),(0,l.kt)("p",null,"Unlike ",(0,l.kt)("inlineCode",{parentName:"p"},"status"),", which will skip a task if it is up to date and continue executing tasks that depend on it, a ",(0,l.kt)("inlineCode",{parentName:"p"},"precondition")," will fail a task, along with any other tasks that depend on it."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'3\'\n\ntasks:\n task-will-fail:\n preconditions:\n - sh: "exit 1"\n\n task-will-also-fail:\n deps:\n - task-will-fail\n\n task-will-still-fail:\n cmds:\n - task: task-will-fail\n - echo "I will not run"\n')),(0,l.kt)("h3",{id:"\u5728\u4efb\u52a1\u8fd0\u884c\u65f6\u9650\u5236"},"\u5728\u4efb\u52a1\u8fd0\u884c\u65f6\u9650\u5236"),(0,l.kt)("p",null,"If a task executed by multiple ",(0,l.kt)("inlineCode",{parentName:"p"},"cmds")," or multiple ",(0,l.kt)("inlineCode",{parentName:"p"},"deps")," you can control when it is executed using ",(0,l.kt)("inlineCode",{parentName:"p"},"run"),". ",(0,l.kt)("inlineCode",{parentName:"p"},"run")," can also be set at the root of the Taskfile to change the behavior of all the tasks unless explicitly overridden."),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"run")," \u652f\u6301\u7684\u503c\uff1a"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"always")," (default) always attempt to invoke the task regardless of the number of previous executions"),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"once")," only invoke this task once regardless of the number of references"),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"when_changed")," only invokes the task once for each unique set of variables passed into the task")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n default:\n cmds:\n - task: generate-file\n vars: { CONTENT: '1' }\n - task: generate-file\n vars: { CONTENT: '2' }\n - task: generate-file\n vars: { CONTENT: '2' }\n\n generate-file:\n run: when_changed\n deps:\n - install-deps\n cmds:\n - echo {{.CONTENT}}\n\n install-deps:\n run: once\n cmds:\n - sleep 5 # long operation like installing packages\n")),(0,l.kt)("h2",{id:"\u53d8\u91cf"},"\u53d8\u91cf"),(0,l.kt)("p",null,"\u5728\u8fdb\u884c\u53d8\u91cf\u63d2\u503c\u65f6\uff0cTask \u5c06\u67e5\u627e\u4ee5\u4e0b\u5185\u5bb9\u3002 \u5b83\u4eec\u6309\u6743\u91cd\u987a\u5e8f\u5217\u5728\u4e0b\u9762\uff08\u5373\u6700\u91cd\u8981\u7684\u7b2c\u4e00\u4f4d\uff09\uff1a"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"Variables declared in the task definition"),(0,l.kt)("li",{parentName:"ul"},"Variables given while calling a task from another (See ",(0,l.kt)("a",{parentName:"li",href:"#calling-another-task"},"Calling another task")," above)"),(0,l.kt)("li",{parentName:"ul"},"Variables of the ",(0,l.kt)("a",{parentName:"li",href:"#including-other-taskfiles"},"included Taskfile")," (when the task is included)"),(0,l.kt)("li",{parentName:"ul"},"Variables of the ",(0,l.kt)("a",{parentName:"li",href:"#vars-of-included-taskfiles"},"inclusion of the Taskfile")," (when the task is included)"),(0,l.kt)("li",{parentName:"ul"},"Global variables (those declared in the ",(0,l.kt)("inlineCode",{parentName:"li"},"vars:")," option in the Taskfile)"),(0,l.kt)("li",{parentName:"ul"},"Environment variables")),(0,l.kt)("p",null,"\u4f7f\u7528\u73af\u5883\u53d8\u91cf\u4f20\u8f93\u53c2\u6570\u7684\u793a\u4f8b\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"$ TASK_VARIABLE=a-value task do-something\n")),(0,l.kt)("admonition",{type:"tip"},(0,l.kt)("p",{parentName:"admonition"},"A special variable ",(0,l.kt)("inlineCode",{parentName:"p"},".TASK")," is always available containing the task name.")),(0,l.kt)("p",null,"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."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},'$ task write-file FILE=file.txt "CONTENT=Hello, World!" print "MESSAGE=All done!"\n')),(0,l.kt)("p",null,"Example of locally declared vars:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n print-var:\n cmds:\n - echo \"{{.VAR}}\"\n vars:\n VAR: Hello!\n")),(0,l.kt)("p",null,"Example of global vars in a ",(0,l.kt)("inlineCode",{parentName:"p"},"Taskfile.yml"),":"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nvars:\n GREETING: Hello from Taskfile!\n\ntasks:\n greet:\n cmds:\n - echo \"{{.GREETING}}\"\n")),(0,l.kt)("h3",{id:"\u52a8\u6001\u53d8\u91cf"},"\u52a8\u6001\u53d8\u91cf"),(0,l.kt)("p",null,"The below syntax (",(0,l.kt)("inlineCode",{parentName:"p"},"sh:")," prop in a variable) is considered a dynamic variable. The value will be treated as a command and the output assigned. If there are one or more trailing newlines, the last newline will be trimmed."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n cmds:\n - go build -ldflags=\"-X main.Version={{.GIT_COMMIT}}\" main.go\n vars:\n GIT_COMMIT:\n sh: git log -n 1 --format=%h\n")),(0,l.kt)("p",null,"This works for all types of variables."),(0,l.kt)("h2",{id:"\u5c06-cli-\u53c2\u6570\u8f6c\u53d1\u5230-cmds"},"\u5c06 CLI \u53c2\u6570\u8f6c\u53d1\u5230 cmds"),(0,l.kt)("p",null,"If ",(0,l.kt)("inlineCode",{parentName:"p"},"--")," is given in the CLI, all following parameters are added to a special ",(0,l.kt)("inlineCode",{parentName:"p"},".CLI_ARGS")," variable. This is useful to forward arguments to another command."),(0,l.kt)("p",null,"The below example will run ",(0,l.kt)("inlineCode",{parentName:"p"},"yarn install"),"."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"$ task yarn -- install\n")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n yarn:\n cmds:\n - yarn {{.CLI_ARGS}}\n")),(0,l.kt)("h2",{id:"\u4f7f\u7528-defer-\u505a-task-\u6e05\u7406"},"\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"h2"},"defer")," \u505a task \u6e05\u7406"),(0,l.kt)("p",null,"With the ",(0,l.kt)("inlineCode",{parentName:"p"},"defer")," keyword, it's possible to schedule cleanup to be run once the task finishes. The difference with just putting it as the last command is that this command will run even when the task fails."),(0,l.kt)("p",null,"In the example below, ",(0,l.kt)("inlineCode",{parentName:"p"},"rm -rf tmpdir/")," will run even if the third command fails:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n default:\n cmds:\n - mkdir -p tmpdir/\n - defer: rm -rf tmpdir/\n - echo 'Do work on tmpdir/'\n")),(0,l.kt)("p",null,"If you want to move the cleanup command into another task, that is possible as well:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n default:\n cmds:\n - mkdir -p tmpdir/\n - defer: { task: cleanup }\n - echo 'Do work on tmpdir/'\n\n cleanup: rm -rf tmpdir/\n")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"Due to the nature of how the ",(0,l.kt)("a",{parentName:"p",href:"https://go.dev/tour/flowcontrol/13"},"Go's own ",(0,l.kt)("inlineCode",{parentName:"a"},"defer")," work"),", the deferred commands are executed in the reverse order if you schedule multiple of them.")),(0,l.kt)("h2",{id:"go-\u7684\u6a21\u677f\u5f15\u64ce"},"Go \u7684\u6a21\u677f\u5f15\u64ce"),(0,l.kt)("p",null,"\u4efb\u52a1\u5728\u6267\u884c\u547d\u4ee4\u4e4b\u524d\u5c06\u547d\u4ee4\u89e3\u6790\u4e3a ",(0,l.kt)("a",{parentName:"p",href:"https://golang.org/pkg/text/template/"},"Go \u7684\u6a21\u677f\u5f15\u64ce"),"\u3002 \u53ef\u4ee5\u901a\u8fc7\u70b9\u8bed\u6cd5 (",(0,l.kt)("inlineCode",{parentName:"p"},".VARNAME"),") \u8bbf\u95ee\u53d8\u91cf\u3002"),(0,l.kt)("p",null,"Go \u7684 ",(0,l.kt)("a",{parentName:"p",href:"https://go-task.github.io/slim-sprig/"},"slim-sprig \u5e93")," \u7684\u6240\u6709\u529f\u80fd\u90fd\u53ef\u7528\u3002 \u4ee5\u4e0b\u793a\u4f8b\u6309\u7167\u7ed9\u5b9a\u683c\u5f0f\u83b7\u53d6\u5f53\u524d\u65e5\u671f\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n print-date:\n cmds:\n - echo {{now | date \"2006-01-02\"}}\n")),(0,l.kt)("p",null,"Task \u8fd8\u589e\u52a0\u4e86\u4ee5\u4e0b\u529f\u80fd\uff1a"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"OS"),': Returns the operating system. Possible values are "windows", "linux", "darwin" (macOS) and "freebsd".'),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"ARCH"),': return the architecture Task was compiled to: "386", "amd64", "arm" or "s390x".'),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"splitLines"),": Splits Unix (\\n) and Windows (\\r\\n) styled newlines."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"catLines"),": Replaces Unix (\\n) and Windows (\\r\\n) styled newlines with a space."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"toSlash"),": Does nothing on Unix, but on Windows converts a string from ",(0,l.kt)("inlineCode",{parentName:"li"},"\\")," path format to ",(0,l.kt)("inlineCode",{parentName:"li"},"/"),"."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"fromSlash"),": Opposite of ",(0,l.kt)("inlineCode",{parentName:"li"},"toSlash"),". Does nothing on Unix, but on Windows converts a string from ",(0,l.kt)("inlineCode",{parentName:"li"},"/")," path format to ",(0,l.kt)("inlineCode",{parentName:"li"},"\\"),"."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"exeExt"),": Returns the right executable extension for the current OS (",(0,l.kt)("inlineCode",{parentName:"li"},'".exe"')," for Windows, ",(0,l.kt)("inlineCode",{parentName:"li"},'""')," for others)."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"shellQuote"),": Quotes a string to make it safe for use in shell scripts. Task uses ",(0,l.kt)("a",{parentName:"li",href:"https://pkg.go.dev/mvdan.cc/sh/v3@v3.4.0/syntax#Quote"},"this Go function")," for this. The Bash dialect is assumed."),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"splitArgs"),": Splits a string as if it were a command's arguments. Task uses ",(0,l.kt)("a",{parentName:"li",href:"https://pkg.go.dev/mvdan.cc/sh/v3@v3.4.0/shell#Fields"},"this Go function"))),(0,l.kt)("p",null,"Example:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n print-os:\n cmds:\n - echo '{{OS}} {{ARCH}}'\n - echo '{{if eq OS \"windows\"}}windows-command{{else}}unix-command{{end}}'\n # This will be path/to/file on Unix but path\\to\\file on Windows\n - echo '{{fromSlash \"path/to/file\"}}'\n enumerated-file:\n vars:\n CONTENT: |\n foo\n bar\n cmds:\n - |\n cat << EOF > output.txt\n {{range $i, $line := .CONTENT | splitLines -}}\n {{printf \"%3d\" $i}}: {{$line}}\n {{end}}EOF\n")),(0,l.kt)("h2",{id:"\u5e2e\u52a9"},"\u5e2e\u52a9"),(0,l.kt)("p",null,"\u8fd0\u884c ",(0,l.kt)("inlineCode",{parentName:"p"},"task --list"),"\uff08\u6216 ",(0,l.kt)("inlineCode",{parentName:"p"},"task -l"),"\uff09\u5217\u51fa\u6240\u6709\u5e26\u6709\u63cf\u8ff0\u7684\u4efb\u52a1\u3002 \u4ee5\u4e0b Taskfile\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build:\n desc: Build the go binary.\n cmds:\n - go build -v -i main.go\n\n test:\n desc: Run all the go tests.\n cmds:\n - go test -race ./...\n\n js:\n cmds:\n - esbuild --bundle --minify js/index.js > public/bundle.js\n\n css:\n cmds:\n - esbuild --bundle --minify css/index.css > public/bundle.css\n")),(0,l.kt)("p",null,"\u5c06\u6253\u5370\u4ee5\u4e0b\u8f93\u51fa\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"* build: Build the go binary.\n* test: Run all the go tests.\n")),(0,l.kt)("p",null,"\u5982\u679c\u60a8\u60f3\u67e5\u770b\u6240\u6709\u4efb\u52a1\uff0c\u8fd8\u6709\u4e00\u4e2a ",(0,l.kt)("inlineCode",{parentName:"p"},"--list-all"),"\uff08\u522b\u540d ",(0,l.kt)("inlineCode",{parentName:"p"},"-a"),"\uff09\u6807\u5fd7\u3002"),(0,l.kt)("h2",{id:"\u663e\u793a\u4efb\u52a1\u6458\u8981"},"\u663e\u793a\u4efb\u52a1\u6458\u8981"),(0,l.kt)("p",null,"\u8fd0\u884c ",(0,l.kt)("inlineCode",{parentName:"p"},"task --summary task-name")," \u5c06\u663e\u793a\u4efb\u52a1\u7684\u6458\u8981\u3002 \u4ee5\u4e0b Taskfile\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n release:\n deps: [build]\n summary: |\n \u53d1\u5e03\u4f60\u7684\u9879\u76ee\u5230 github\n\n \u5b83\u5c06\u5728\u5f00\u59cb\u53d1\u5e03\u4e4b\u524d\u6784\u5efa\u60a8\u7684\u9879\u76ee\u3002\n \u8bf7\u786e\u4fdd\u60a8\u5728\u5f00\u59cb\u4e4b\u524d\u5df2\u7ecf\u8bbe\u7f6e\u4e86 GITHUB_TOKEN\u3002\n cmds:\n - your-release-tool\n\n build:\n cmds:\n - your-build-tool\n")),(0,l.kt)("p",null,"\u8fd0\u884c ",(0,l.kt)("inlineCode",{parentName:"p"},"task --summary release")," \u5c06\u6253\u5370\u4ee5\u4e0b\u8f93\u51fa\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre"},"task: release\n\n\u53d1\u5e03\u4f60\u7684\u9879\u76ee\u5230 github\n\n\u5b83\u5c06\u5728\u5f00\u59cb\u53d1\u5e03\u4e4b\u524d\u6784\u5efa\u60a8\u7684\u9879\u76ee\u3002\n\u8bf7\u786e\u4fdd\u60a8\u5728\u5f00\u59cb\u4e4b\u524d\u5df2\u7ecf\u8bbe\u7f6e\u4e86 GITHUB_TOKEN\u3002\n\ndependencies:\n - build\n\ncommands:\n - your-release-tool\n")),(0,l.kt)("p",null,"\u5982\u679c\u7f3a\u5c11\u6458\u8981\uff0c\u5c06\u6253\u5370\u63cf\u8ff0\u3002 \u5982\u679c\u4efb\u52a1\u6ca1\u6709\u6458\u8981\u6216\u63cf\u8ff0\uff0c\u5219\u4f1a\u6253\u5370\u4e00\u6761\u8b66\u544a\u3002"),(0,l.kt)("p",null,"\u8bf7\u6ce8\u610f\uff1a",(0,l.kt)("em",{parentName:"p"},"\u663e\u793a\u6458\u8981\u4e0d\u4f1a\u6267\u884c\u547d\u4ee4"),"\u3002"),(0,l.kt)("h2",{id:"task-\u522b\u540d"},"Task \u522b\u540d"),(0,l.kt)("p",null,"Aliases \u662f task \u7684\u66ff\u4ee3\u540d\u79f0\u3002 \u5b83\u4eec\u53ef\u4ee5\u4f7f\u8fd0\u884c\u5177\u6709\u957f\u540d\u79f0\u6216\u96be\u4ee5\u952e\u5165\u540d\u79f0\u7684 task \u53d8\u5f97\u66f4\u52a0\u5bb9\u6613\u548c\u5feb\u901f\u3002 \u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e0a\u4f7f\u7528\u5b83\u4eec\uff0c\u5728\u60a8\u7684 Taskfile \u4e2d ",(0,l.kt)("a",{parentName:"p",href:"#%E8%B0%83%E7%94%A8%E5%8F%A6%E4%B8%80%E4%B8%AA-task"},"\u8c03\u7528\u5b50\u4efb\u52a1")," \u65f6\u4ee5\u53ca\u5728 ",(0,l.kt)("a",{parentName:"p",href:"#%E5%8C%85%E5%90%AB%E5%85%B6%E4%BB%96-taskfile"},"\u5305\u542b\u6765\u81ea\u53e6\u4e00\u4e2a Taskfile")," \u7684\u522b\u540d task \u65f6\u3002 \u5b83\u4eec\u4e5f\u53ef\u4ee5\u4e0e ",(0,l.kt)("a",{parentName:"p",href:"#%E5%91%BD%E5%90%8D%E7%A9%BA%E9%97%B4%E5%88%AB%E5%90%8D"},"\u547d\u540d\u7a7a\u95f4\u522b\u540d")," \u4e00\u8d77\u4f7f\u7528\u3002"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n generate:\n aliases: [gen]\n cmds:\n - task: gen-mocks\n\n generate-mocks:\n aliases: [gen-mocks]\n cmds:\n - echo \"generating...\"\n")),(0,l.kt)("h2",{id:"\u8986\u76d6-task-\u540d\u79f0"},"\u8986\u76d6 Task \u540d\u79f0"),(0,l.kt)("p",null,"Sometimes you may want to override the task name printed on the summary, up-to-date messages to STDOUT, etc. In this case, you can just set ",(0,l.kt)("inlineCode",{parentName:"p"},"label:"),", which can also be interpolated with variables:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n default:\n - task: print\n vars:\n MESSAGE: hello\n - task: print\n vars:\n MESSAGE: world\n\n print:\n label: 'print-{{.MESSAGE}}'\n cmds:\n - echo \"{{.MESSAGE}}\"\n")),(0,l.kt)("h2",{id:"\u9759\u9ed8\u6a21\u5f0f"},"\u9759\u9ed8\u6a21\u5f0f"),(0,l.kt)("p",null,"\u9759\u9ed8\u6a21\u5f0f\u5728 Task \u8fd0\u884c\u547d\u4ee4\u4e4b\u524d\u7981\u7528\u547d\u4ee4\u56de\u663e\u3002 \u5bf9\u4e8e\u4ee5\u4e0b Taskfile\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n echo:\n cmds:\n - echo \"Print something\"\n")),(0,l.kt)("p",null,"\u901a\u5e38\u8fd9\u5c06\u6253\u5370\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-sh"},'echo "Print something"\nPrint something\n')),(0,l.kt)("p",null,"\u5f00\u542f\u9759\u9ed8\u6a21\u5f0f\u540e\uff0c\u5c06\u6253\u5370\u4ee5\u4e0b\u5185\u5bb9\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-sh"},"Print something\n")),(0,l.kt)("p",null,"\u5f00\u542f\u9759\u9ed8\u6a21\u5f0f\u6709\u56db\u79cd\u65b9\u5f0f\uff1a"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"\u5728 cmds \u7ea7\u522b\uff1a")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n echo:\n cmds:\n - cmd: echo \"Print something\"\n silent: true\n")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"\u5728 task \u7ea7\u522b\uff1a")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n echo:\n cmds:\n - echo \"Print something\"\n silent: true\n")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"\u5728 Taskfile \u5168\u5c40\u7ea7\u522b\uff1a")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nsilent: true\n\ntasks:\n echo:\n cmds:\n - echo \"Print something\"\n")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"\u6216\u8005\u5168\u5c40\u4f7f\u7528 ",(0,l.kt)("inlineCode",{parentName:"li"},"--silent")," \u6216 ",(0,l.kt)("inlineCode",{parentName:"li"},"-s")," \u6807\u5fd7")),(0,l.kt)("p",null,"\u5982\u679c\u60a8\u60f3\u6539\u4e3a\u7981\u6b62 STDOUT\uff0c\u53ea\u9700\u5c06\u547d\u4ee4\u91cd\u5b9a\u5411\u5230 ",(0,l.kt)("inlineCode",{parentName:"p"},"/dev/null"),"\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n echo:\n cmds:\n - echo \"This will print nothing\" > /dev/null\n")),(0,l.kt)("h2",{id:"\u8bd5\u8fd0\u884c\u6a21\u5f0f"},"\u8bd5\u8fd0\u884c\u6a21\u5f0f"),(0,l.kt)("p",null,"Dry run mode (",(0,l.kt)("inlineCode",{parentName:"p"},"--dry"),") compiles and steps through each task, printing the commands that would be run without executing them. This is useful for debugging your Taskfiles."),(0,l.kt)("h2",{id:"\u5ffd\u7565\u9519\u8bef"},"\u5ffd\u7565\u9519\u8bef"),(0,l.kt)("p",null,"\u60a8\u53ef\u4ee5\u9009\u62e9\u5728\u547d\u4ee4\u6267\u884c\u671f\u95f4\u5ffd\u7565\u9519\u8bef\u3002 \u7ed9\u5b9a\u4ee5\u4e0b Taskfile\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n echo:\n cmds:\n - exit 1\n - echo \"Hello World\"\n")),(0,l.kt)("p",null,"Task will abort the execution after running ",(0,l.kt)("inlineCode",{parentName:"p"},"exit 1")," because the status code ",(0,l.kt)("inlineCode",{parentName:"p"},"1")," stands for ",(0,l.kt)("inlineCode",{parentName:"p"},"EXIT_FAILURE"),". However, it is possible to continue with execution using ",(0,l.kt)("inlineCode",{parentName:"p"},"ignore_error"),":"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n echo:\n cmds:\n - cmd: exit 1\n ignore_error: true\n - echo \"Hello World\"\n")),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"ignore_error")," can also be set for a task, which means errors will be suppressed for all commands. Nevertheless, keep in mind that this option will not propagate to other tasks called either by ",(0,l.kt)("inlineCode",{parentName:"p"},"deps")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"cmds"),"!"),(0,l.kt)("h2",{id:"\u8f93\u51fa\u8bed\u6cd5"},"\u8f93\u51fa\u8bed\u6cd5"),(0,l.kt)("p",null,"By default, Task just redirects the STDOUT and STDERR of the running commands to the shell in real-time. This is good for having live feedback for logging printed by commands, but the output can become messy if you have multiple commands running simultaneously and printing lots of stuff."),(0,l.kt)("p",null,"\u4e3a\u4e86\u4f7f\u5176\u66f4\u5177\u53ef\u5b9a\u5236\u6027\uff0c\u76ee\u524d\u60a8\u53ef\u4ee5\u9009\u62e9\u4e09\u79cd\u4e0d\u540c\u7684\u8f93\u51fa\u9009\u9879\uff1a"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"interleaved")," (\u9ed8\u8ba4)"),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"group")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"prefixed"))),(0,l.kt)("p",null,"\u8981\u9009\u62e9\u53e6\u4e00\u4e2a\uff0c\u53ea\u9700\u5728 Taskfile \u6839\u76ee\u5f55\u4e2d\u8bbe\u7f6e\u5373\u53ef\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\noutput: 'group'\n\ntasks:\n # ...\n")),(0,l.kt)("p",null,(0,l.kt)("inlineCode",{parentName:"p"},"group")," \u8f93\u51fa\u5c06\u5728\u547d\u4ee4\u5b8c\u6210\u540e\u6253\u5370\u4e00\u6b21\u547d\u4ee4\u7684\u5168\u90e8\u8f93\u51fa\uff0c\u56e0\u6b64\u60a8\u4e0d\u4f1a\u5bf9\u9700\u8981\u5f88\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u547d\u4ee4\u6709\u5b9e\u65f6\u53cd\u9988\u3002"),(0,l.kt)("p",null,"When using the ",(0,l.kt)("inlineCode",{parentName:"p"},"group")," output, you can optionally provide a templated message to print at the start and end of the group. This can be useful for instructing CI systems to group all of the output for a given task, such as with ",(0,l.kt)("a",{parentName:"p",href:"https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#grouping-log-lines"},"GitHub Actions' ",(0,l.kt)("inlineCode",{parentName:"a"},"::group::")," command")," or ",(0,l.kt)("a",{parentName:"p",href:"https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?expand=1&view=azure-devops&tabs=bash#formatting-commands"},"Azure Pipelines"),"."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\noutput:\n group:\n begin: '::group::{{.TASK}}'\n end: '::endgroup::'\n\ntasks:\n default:\n cmds:\n - echo 'Hello, World!'\n silent: true\n")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"$ task default\n::group::default\nHello, World!\n::endgroup::\n")),(0,l.kt)("p",null,"When using the ",(0,l.kt)("inlineCode",{parentName:"p"},"group")," output, you may swallow the output of the executed command on standard output and standard error if it does not fail (zero exit code)."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nsilent: true\n\noutput:\n group:\n error_only: true\n\ntasks:\n passes: echo 'output-of-passes'\n errors: echo 'output-of-errors' && exit 1\n")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},'$ task passes\n$ task errors\noutput-of-errors\ntask: Failed to run task "errors": exit status 1\n')),(0,l.kt)("p",null,"The ",(0,l.kt)("inlineCode",{parentName:"p"},"prefix")," output will prefix every line printed by a command with ",(0,l.kt)("inlineCode",{parentName:"p"},"[task-name]")," as the prefix, but you can customize the prefix for a command with the ",(0,l.kt)("inlineCode",{parentName:"p"},"prefix:")," attribute:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},'version: \'3\'\n\noutput: prefixed\n\ntasks:\n default:\n deps:\n - task: print\n vars: {TEXT: foo}\n - task: print\n vars: {TEXT: bar}\n - task: print\n vars: {TEXT: baz}\n\n print:\n cmds:\n - echo "{{.TEXT}}"\n prefix: "print-{{.TEXT}}"\n silent: true\n')),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"$ task default\n[print-foo] foo\n[print-bar] bar\n[print-baz] baz\n")),(0,l.kt)("admonition",{type:"tip"},(0,l.kt)("p",{parentName:"admonition"},"The ",(0,l.kt)("inlineCode",{parentName:"p"},"output")," option can also be specified by the ",(0,l.kt)("inlineCode",{parentName:"p"},"--output")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"-o")," flags.")),(0,l.kt)("h2",{id:"\u4ea4\u4e92\u5f0f-cli-\u5e94\u7528"},"\u4ea4\u4e92\u5f0f CLI \u5e94\u7528"),(0,l.kt)("p",null,"When running interactive CLI applications inside Task they can sometimes behave weirdly, especially when the ",(0,l.kt)("a",{parentName:"p",href:"#output-syntax"},"output mode")," is set to something other than ",(0,l.kt)("inlineCode",{parentName:"p"},"interleaved")," (the default), or when interactive apps are run in parallel with other tasks."),(0,l.kt)("p",null,"The ",(0,l.kt)("inlineCode",{parentName:"p"},"interactive: true")," tells Task this is an interactive application and Task will try to optimize for it:"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n default:\n cmds:\n - vim my-file.txt\n interactive: true\n")),(0,l.kt)("p",null,"If you still have problems running an interactive app through Task, please open an issue about it."),(0,l.kt)("h2",{id:"\u77ed-task-\u8bed\u6cd5"},"\u77ed Task \u8bed\u6cd5"),(0,l.kt)("p",null,"Starting on Task v3, you can now write tasks with a shorter syntax if they have the default settings (e.g. no custom ",(0,l.kt)("inlineCode",{parentName:"p"},"env:"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"vars:"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"desc:"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"silent:")," , etc):"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\ntasks:\n build: go build -v -o ./app{{exeExt}} .\n\n run:\n - task: build\n - ./app{{exeExt}} -h localhost -p 8080\n")),(0,l.kt)("h2",{id:"set-\u548c-shopt"},(0,l.kt)("inlineCode",{parentName:"h2"},"set")," \u548c ",(0,l.kt)("inlineCode",{parentName:"h2"},"shopt")),(0,l.kt)("p",null,"It's possible to specify options to the ",(0,l.kt)("a",{parentName:"p",href:"https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html"},(0,l.kt)("inlineCode",{parentName:"a"},"set"))," and ",(0,l.kt)("a",{parentName:"p",href:"https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html"},(0,l.kt)("inlineCode",{parentName:"a"},"shopt"))," builtins. This can be added at global, task or command level."),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-yaml"},"version: '3'\n\nset: [pipefail]\nshopt: [globstar]\n\ntasks:\n # `globstar` required for double star globs to work\n default: echo **/*.go\n")),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"Keep in mind that not all options are available in the ",(0,l.kt)("a",{parentName:"p",href:"https://github.com/mvdan/sh"},"shell interpreter library")," that Task uses.")),(0,l.kt)("h2",{id:"\u89c2\u5bdf\u4efb\u52a1"},"\u89c2\u5bdf\u4efb\u52a1"),(0,l.kt)("p",null,"With the flags ",(0,l.kt)("inlineCode",{parentName:"p"},"--watch")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"-w")," task will watch for file changes and run the task again. This requires the ",(0,l.kt)("inlineCode",{parentName:"p"},"sources")," attribute to be given, so task knows which files to watch."),(0,l.kt)("p",null,"The default watch interval is 5 seconds, but it's possible to change it by either setting ",(0,l.kt)("inlineCode",{parentName:"p"},"interval: '500ms'")," in the root of the Taskfile passing it as an argument like ",(0,l.kt)("inlineCode",{parentName:"p"},"--interval=500ms"),"."))}k.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/zh-Hans/assets/js/4fc1c6af.272f7b37.js b/zh-Hans/assets/js/4fc1c6af.272f7b37.js new file mode 100644 index 00000000..6cd1734a --- /dev/null +++ b/zh-Hans/assets/js/4fc1c6af.272f7b37.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktaskfile_dev=self.webpackChunktaskfile_dev||[]).push([[2],{3905:function(e,t,a){a.d(t,{Zo:function(){return k},kt:function(){return h}});var n=a(7294);function l(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function r(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function o(e){for(var t=1;t=0||(l[a]=e[a]);return l}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(l[a]=e[a])}return l}var s=n.createContext({}),i=function(e){var t=n.useContext(s),a=t;return e&&(a="function"==typeof e?e(t):o(o({},t),e)),a},k=function(e){var t=i(e.components);return n.createElement(s.Provider,{value:t},e.children)},u="mdxType",c={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},m=n.forwardRef((function(e,t){var a=e.components,l=e.mdxType,r=e.originalType,s=e.parentName,k=p(e,["components","mdxType","originalType","parentName"]),u=i(a),m=l,h=u["".concat(s,".").concat(m)]||u[m]||c[m]||r;return a?n.createElement(h,o(o({ref:t},k),{},{components:a})):n.createElement(h,o({ref:t},k))}));function h(e,t){var a=arguments,l=t&&t.mdxType;if("string"==typeof e||l){var r=a.length,o=new Array(r);o[0]=m;var p={};for(var s in t)hasOwnProperty.call(t,s)&&(p[s]=t[s]);p.originalType=e,p[u]="string"==typeof e?e:l,o[1]=p;for(var i=2;i=0||(l[a]=e[a]);return l}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(l[a]=e[a])}return l}var s=n.createContext({}),i=function(e){var t=n.useContext(s),a=t;return e&&(a="function"==typeof e?e(t):o(o({},t),e)),a},k=function(e){var t=i(e.components);return n.createElement(s.Provider,{value:t},e.children)},u="mdxType",c={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},m=n.forwardRef((function(e,t){var a=e.components,l=e.mdxType,r=e.originalType,s=e.parentName,k=p(e,["components","mdxType","originalType","parentName"]),u=i(a),m=l,h=u["".concat(s,".").concat(m)]||u[m]||c[m]||r;return a?n.createElement(h,o(o({ref:t},k),{},{components:a})):n.createElement(h,o({ref:t},k))}));function h(e,t){var a=arguments,l=t&&t.mdxType;if("string"==typeof e||l){var r=a.length,o=new Array(r);o[0]=m;var p={};for(var s in t)hasOwnProperty.call(t,s)&&(p[s]=t[s]);p.originalType=e,p[u]="string"==typeof e?e:l,o[1]=p;for(var i=2;i=0||(T[D]=M[D]);return T}(M,N);if(Object.getOwnPropertySymbols){var z=Object.getOwnPropertySymbols(M);for(j=0;j=0||Object.prototype.propertyIsEnumerable.call(M,D)&&(T[D]=M[D])}return T}var u=j.createContext({}),A=function(M){var N=j.useContext(u),D=N;return M&&(D="function"==typeof M?M(N):I(I({},N),M)),D},E=function(M){var N=A(M.components);return j.createElement(u.Provider,{value:N},M.children)},y="mdxType",O={inlineCode:"code",wrapper:function(M){var N=M.children;return j.createElement(j.Fragment,{},N)}},e=j.forwardRef((function(M,N){var D=M.components,T=M.mdxType,z=M.originalType,u=M.parentName,E=g(M,["components","mdxType","originalType","parentName"]),y=A(D),e=T,t=y["".concat(u,".").concat(e)]||y[e]||O[e]||z;return D?j.createElement(t,I(I({ref:N},E),{},{components:D})):j.createElement(t,I({ref:N},E))}));function t(M,N){var D=arguments,T=N&&N.mdxType;if("string"==typeof M||T){var z=D.length,I=new Array(z);I[0]=e;var g={};for(var u in N)hasOwnProperty.call(N,u)&&(g[u]=N[u]);g.originalType=M,g[y]="string"==typeof M?M:T,I[1]=g;for(var A=2;A=0||(T[D]=M[D]);return T}(M,N);if(Object.getOwnPropertySymbols){var z=Object.getOwnPropertySymbols(M);for(j=0;j=0||Object.prototype.propertyIsEnumerable.call(M,D)&&(T[D]=M[D])}return T}var u=j.createContext({}),A=function(M){var N=j.useContext(u),D=N;return M&&(D="function"==typeof M?M(N):I(I({},N),M)),D},E=function(M){var N=A(M.components);return j.createElement(u.Provider,{value:N},M.children)},O="mdxType",y={inlineCode:"code",wrapper:function(M){var N=M.children;return j.createElement(j.Fragment,{},N)}},e=j.forwardRef((function(M,N){var D=M.components,T=M.mdxType,z=M.originalType,u=M.parentName,E=g(M,["components","mdxType","originalType","parentName"]),O=A(D),e=T,t=O["".concat(u,".").concat(e)]||O[e]||y[e]||z;return D?j.createElement(t,I(I({ref:N},E),{},{components:D})):j.createElement(t,I({ref:N},E))}));function t(M,N){var D=arguments,T=N&&N.mdxType;if("string"==typeof M||T){var z=D.length,I=new Array(z);I[0]=e;var g={};for(var u in N)hasOwnProperty.call(N,u)&&(g[u]=N[u]);g.originalType=M,g[O]="string"==typeof M?M:T,I[1]=g;for(var A=2;A=0||(s[a]=t[a]);return s}(t,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(t,a)&&(s[a]=t[a])}return s}var o=i.createContext({}),k=function(t){var e=i.useContext(o),a=e;return t&&(a="function"==typeof t?t(e):l(l({},e),t)),a},h=function(t){var e=k(t.components);return i.createElement(o.Provider,{value:e},t.children)},m="mdxType",p={inlineCode:"code",wrapper:function(t){var e=t.children;return i.createElement(i.Fragment,{},e)}},u=i.forwardRef((function(t,e){var a=t.components,s=t.mdxType,n=t.originalType,o=t.parentName,h=r(t,["components","mdxType","originalType","parentName"]),m=k(a),u=s,d=m["".concat(o,".").concat(u)]||m[u]||p[u]||n;return a?i.createElement(d,l(l({ref:e},h),{},{components:a})):i.createElement(d,l({ref:e},h))}));function d(t,e){var a=arguments,s=e&&e.mdxType;if("string"==typeof t||s){var n=a.length,l=new Array(n);l[0]=u;var r={};for(var o in e)hasOwnProperty.call(e,o)&&(r[o]=e[o]);r.originalType=t,r[m]="string"==typeof t?t:s,l[1]=r;for(var k=2;k=0||(s[a]=t[a]);return s}(t,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(t,a)&&(s[a]=t[a])}return s}var o=i.createContext({}),k=function(t){var e=i.useContext(o),a=e;return t&&(a="function"==typeof t?t(e):l(l({},e),t)),a},h=function(t){var e=k(t.components);return i.createElement(o.Provider,{value:e},t.children)},m="mdxType",p={inlineCode:"code",wrapper:function(t){var e=t.children;return i.createElement(i.Fragment,{},e)}},u=i.forwardRef((function(t,e){var a=t.components,s=t.mdxType,n=t.originalType,o=t.parentName,h=r(t,["components","mdxType","originalType","parentName"]),m=k(a),u=s,d=m["".concat(o,".").concat(u)]||m[u]||p[u]||n;return a?i.createElement(d,l(l({ref:e},h),{},{components:a})):i.createElement(d,l({ref:e},h))}));function d(t,e){var a=arguments,s=e&&e.mdxType;if("string"==typeof t||s){var n=a.length,l=new Array(n);l[0]=u;var r={};for(var o in e)hasOwnProperty.call(e,o)&&(r[o]=e[o]);r.originalType=t,r[m]="string"==typeof t?t:s,l[1]=r;for(var k=2;k=o)&&Object.keys(u.O).every((function(e){return u.O[e](n[i])}))?n.splice(i--,1):(a=!1,o0&&e[d-1][2]>o;d--)e[d]=e[d-1];e[d]=[n,r,o]},u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},n=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},u.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var o=Object.create(null);u.r(o);var f={};t=t||[null,n({}),n([]),n(n)];for(var a=2&r&&e;"object"==typeof a&&!~t.indexOf(a);a=n(a))Object.getOwnPropertyNames(a).forEach((function(t){f[t]=function(){return e[t]}}));return f.default=function(){return e},u.d(o,f),o},u.d=function(e,t){for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.f={},u.e=function(e){return Promise.all(Object.keys(u.f).reduce((function(t,n){return u.f[n](e,t),t}),[]))},u.u=function(e){return"assets/js/"+({2:"4fc1c6af",31:"51de5da2",38:"14b2bd35",53:"935f2afb",97:"835b845c",133:"f1d66b0d",188:"dd4fb81f",425:"87f30f6b",514:"1be78505",595:"d0766b26",597:"8152bf4e",634:"1fd60438",701:"01713e21",825:"0f29a59d",863:"5b2a233e",868:"8faba80b",889:"49514f56",918:"17896441",920:"1a4e3797"}[e]||e)+"."+{2:"6c073004",31:"ae755056",38:"0e400898",53:"6c08fc98",97:"8b44cfc3",133:"6862b446",188:"c0f13317",425:"4227404d",514:"9062895a",595:"c5627647",597:"24dd0f67",634:"5f0b27aa",701:"3f827c94",780:"b979b06f",825:"74edccf0",863:"d9ce1ba9",868:"eb9006a5",889:"75ba2656",894:"4bf7d380",918:"e75765f6",920:"a9132d06",945:"3694633c",972:"01a5a892"}[e]+".js"},u.miniCssF=function(e){},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r={},o="taskfile-dev:",u.l=function(e,t,n,f){if(r[e])r[e].push(t);else{var a,i;if(void 0!==n)for(var c=document.getElementsByTagName("script"),d=0;d=o)&&Object.keys(u.O).every((function(e){return u.O[e](n[i])}))?n.splice(i--,1):(a=!1,o0&&e[d-1][2]>o;d--)e[d]=e[d-1];e[d]=[n,r,o]},u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},n=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},u.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var o=Object.create(null);u.r(o);var f={};t=t||[null,n({}),n([]),n(n)];for(var a=2&r&&e;"object"==typeof a&&!~t.indexOf(a);a=n(a))Object.getOwnPropertyNames(a).forEach((function(t){f[t]=function(){return e[t]}}));return f.default=function(){return e},u.d(o,f),o},u.d=function(e,t){for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.f={},u.e=function(e){return Promise.all(Object.keys(u.f).reduce((function(t,n){return u.f[n](e,t),t}),[]))},u.u=function(e){return"assets/js/"+({2:"4fc1c6af",31:"51de5da2",38:"14b2bd35",53:"935f2afb",97:"835b845c",133:"f1d66b0d",188:"dd4fb81f",425:"87f30f6b",514:"1be78505",595:"d0766b26",597:"8152bf4e",634:"1fd60438",701:"01713e21",825:"0f29a59d",863:"5b2a233e",868:"8faba80b",889:"49514f56",918:"17896441",920:"1a4e3797"}[e]||e)+"."+{2:"272f7b37",31:"ae755056",38:"0e400898",53:"6c08fc98",97:"8b44cfc3",133:"6862b446",188:"c0f13317",425:"01b126ab",514:"9062895a",595:"c5627647",597:"24dd0f67",634:"5f0b27aa",701:"d102d208",780:"b979b06f",825:"74edccf0",863:"87d3f982",868:"eb9006a5",889:"75ba2656",894:"4bf7d380",918:"e75765f6",920:"a9132d06",945:"3694633c",972:"01a5a892"}[e]+".js"},u.miniCssF=function(e){},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r={},o="taskfile-dev:",u.l=function(e,t,n,f){if(r[e])r[e].push(t);else{var a,i;if(void 0!==n)for(var c=document.getElementsByTagName("script"),d=0;d