mirror of
https://github.com/go-task/task.git
synced 2025-05-21 22:43:13 +02:00
chore: changelog for #1633
This commit is contained in:
parent
4b6c79aca5
commit
1f2cbfb932
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
- Added
|
||||||
|
[Env Precedence Experiment](https://taskfile.dev/experiments/env-precedence)
|
||||||
|
(#1038, #1633 by @vmaerten).
|
||||||
- Added a CI lint job to ensure that the docs are updated correctly (#1719 by
|
- Added a CI lint job to ensure that the docs are updated correctly (#1719 by
|
||||||
@vmaerten).
|
@vmaerten).
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
draft: false # Hide in production
|
|
||||||
slug: '/experiments/env-precedence'
|
slug: '/experiments/env-precedence'
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -23,13 +22,15 @@ This experiment breaks the following functionality:
|
|||||||
|
|
||||||
:::info
|
:::info
|
||||||
|
|
||||||
To enable this experiment, set the environment variable: `TASK_X_ENV_PRECEDENCE=1`.
|
To enable this experiment, set the environment variable:
|
||||||
Check out [our guide to enabling experiments ][enabling-experiments] for more
|
`TASK_X_ENV_PRECEDENCE=1`. Check out [our guide to enabling
|
||||||
information.
|
experiments][enabling-experiments] for more information.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
Before this experiment, the OS variable took precedence over the task environment variable. This experiment changes the precedence to make the task environment variable take precedence over the OS variable.
|
Before this experiment, the OS variable took precedence over the task
|
||||||
|
environment variable. This experiment changes the precedence to make the task
|
||||||
|
environment variable take precedence over the OS variable.
|
||||||
|
|
||||||
Consider the following example:
|
Consider the following example:
|
||||||
|
|
||||||
@ -43,9 +44,11 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- echo "$KEY"
|
- echo "$KEY"
|
||||||
```
|
```
|
||||||
Running `KEY=some task` before this experiment, the output would be `some`, but after this experiment, the output would be `other`.
|
Running `KEY=some task` before this experiment, the output would be `some`, but
|
||||||
|
after this experiment, the output would be `other`.
|
||||||
|
|
||||||
If you still want to get the OS variable, you can use the template function env like follow : `{{env "OS_VAR"}}`.
|
If you still want to get the OS variable, you can use the template function env
|
||||||
|
like follow : `{{env "OS_VAR"}}`.
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
version: '3'
|
version: '3'
|
||||||
@ -60,7 +63,8 @@ tasks:
|
|||||||
```
|
```
|
||||||
Running `KEY=some task`, the output would be `other` and `some`.
|
Running `KEY=some task`, the output would be `other` and `some`.
|
||||||
|
|
||||||
Like other variables/envs, you can also fall back to a given value using the default template function:
|
Like other variables/envs, you can also fall back to a given value using the
|
||||||
|
default template function:
|
||||||
```yml
|
```yml
|
||||||
MY_ENV: '{{.MY_ENV | default "fallback"}}'
|
MY_ENV: '{{.MY_ENV | default "fallback"}}'
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user