mirror of
https://github.com/go-task/task.git
synced 2025-11-25 22:32:55 +02:00
feat: add ROOT_TASKFILE special variable (#1469)
This commit is contained in:
@@ -128,8 +128,9 @@ There are some special variables that is available on the templating system:
|
|||||||
| `CLI_ARGS` | Contain all extra arguments passed after `--` when calling Task through the CLI. |
|
| `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_FORCE` | A boolean containing whether the `--force` or `--force-all` flags were set. |
|
||||||
| `TASK` | The name of the current task. |
|
| `TASK` | The name of the current task. |
|
||||||
| `ROOT_DIR` | The absolute path of the root Taskfile. |
|
| `ROOT_TASKFILE` | The absolute path of the root Taskfile. |
|
||||||
| `TASKFILE_DIR` | The absolute path of the included Taskfile. |
|
| `ROOT_DIR` | The absolute path of the root Taskfile directory. |
|
||||||
|
| `TASKFILE_DIR` | The absolute path of the included Taskfile directory. |
|
||||||
| `USER_WORKING_DIR` | The absolute path of the directory `task` was called from. |
|
| `USER_WORKING_DIR` | The absolute path of the directory `task` was called from. |
|
||||||
| `CHECKSUM` | The checksum of the files listed in `sources`. Only available within the `status` prop and if method is set to `checksum`. |
|
| `CHECKSUM` | The checksum of the files listed in `sources`. Only available within the `status` prop and if method is set to `checksum`. |
|
||||||
| `TIMESTAMP` | The date object of the greatest timestamp of the files listed in `sources`. Only available within the `status` prop and if method is set to `timestamp`. |
|
| `TIMESTAMP` | The date object of the greatest timestamp of the files listed in `sources`. Only available within the `status` prop and if method is set to `timestamp`. |
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
|
|
||||||
type Compiler struct {
|
type Compiler struct {
|
||||||
Dir string
|
Dir string
|
||||||
|
Entrypoint string
|
||||||
UserWorkingDir string
|
UserWorkingDir string
|
||||||
|
|
||||||
TaskfileEnv *ast.Vars
|
TaskfileEnv *ast.Vars
|
||||||
@@ -214,6 +215,7 @@ func (c *Compiler) getSpecialVars(t *ast.Task) (map[string]string, error) {
|
|||||||
|
|
||||||
return map[string]string{
|
return map[string]string{
|
||||||
"TASK": t.Task,
|
"TASK": t.Task,
|
||||||
|
"ROOT_TASKFILE": filepathext.SmartJoin(c.Dir, c.Entrypoint),
|
||||||
"ROOT_DIR": c.Dir,
|
"ROOT_DIR": c.Dir,
|
||||||
"TASKFILE_DIR": taskfileDir,
|
"TASKFILE_DIR": taskfileDir,
|
||||||
"USER_WORKING_DIR": c.UserWorkingDir,
|
"USER_WORKING_DIR": c.UserWorkingDir,
|
||||||
|
|||||||
1
setup.go
1
setup.go
@@ -189,6 +189,7 @@ func (e *Executor) setupCompiler() error {
|
|||||||
|
|
||||||
e.Compiler = &compiler.Compiler{
|
e.Compiler = &compiler.Compiler{
|
||||||
Dir: e.Dir,
|
Dir: e.Dir,
|
||||||
|
Entrypoint: e.Entrypoint,
|
||||||
UserWorkingDir: e.UserWorkingDir,
|
UserWorkingDir: e.UserWorkingDir,
|
||||||
TaskfileEnv: e.Taskfile.Env,
|
TaskfileEnv: e.Taskfile.Env,
|
||||||
TaskfileVars: e.Taskfile.Vars,
|
TaskfileVars: e.Taskfile.Vars,
|
||||||
|
|||||||
Reference in New Issue
Block a user