Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add template variable for watch trigger #1725

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ func (e *Executor) watchTasks(calls ...*ast.Call) error {

for _, c := range calls {
c := c
c.Vars.Set("CHANGED_ABS", ast.Var{Value: event.Path})
c.Vars.Set("CHANGED_FILE", ast.Var{Value: event.FileInfo.Name()})
go func() {
if err := e.RunTask(ctx, c); err != nil && !isContextError(err) {
e.Logger.Errf(logger.Red, "%v\n", err)
Expand Down
2 changes: 2 additions & 0 deletions website/docs/reference/templating.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ special variable will be overridden.

| Var | Description |
|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `CHANGED_ABS` | The absolute path to the file that triggered the task run. Only avaible when using [`watch`](../../usage/#watch-tasks). |
| `CHANGED_FILE` | The name of the file that triggered the task run. Only avaible when using [`watch`](../../usage/#watch-tasks). |
| `CLI_ARGS` | Contain all extra arguments passed after `--` when calling Task through the CLI. |
| `CLI_FORCE` | A boolean containing whether the `--force` or `--force-all` flags were set. |
| `CLI_SILENT` | A boolean containing whether the `--silent` flag was set. |
Expand Down