1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

feat(defer): expose EXIT_CODE special variable to defer: (#1762)

Co-authored-by: Dor Sahar <dorsahar@icloud.com>
This commit is contained in:
Andrey Nering
2024-08-14 22:53:14 -03:00
committed by GitHub
parent 35119c12ab
commit b259edeb65
8 changed files with 93 additions and 14 deletions

View File

@@ -161,6 +161,12 @@ func (e *Executor) compiledTask(call *ast.Call, evaluateShVars bool) (*ast.Task,
}
continue
}
// Defer commands are replaced in a lazy manner because
// we need to include EXIT_CODE.
if cmd.Defer {
new.Cmds = append(new.Cmds, cmd.DeepCopy())
continue
}
newCmd := cmd.DeepCopy()
newCmd.Cmd = templater.Replace(cmd.Cmd, cache)
newCmd.Task = templater.Replace(cmd.Task, cache)