From 945c72cf6cbb4bd94d8079378074e1384857c973 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sat, 10 Jul 2021 19:46:53 -0300 Subject: [PATCH] Small optimization and bug fix: don't compute variables if not needed for `dotenv:` Closes #517 --- CHANGELOG.md | 5 +++++ taskfile/read/dotenv.go | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81c36aa1..a71ae25c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased + +- Small optimization and bug fix: don't compute variables if not needed for + `dotenv:` ([#517](https://github.com/go-task/task/issues/517)). + ## v3.5.0 - 2021-07-04 - Add support for interpolation in `dotenv:` diff --git a/taskfile/read/dotenv.go b/taskfile/read/dotenv.go index 8d8ffd00..0ce6fed4 100644 --- a/taskfile/read/dotenv.go +++ b/taskfile/read/dotenv.go @@ -12,6 +12,10 @@ import ( ) func Dotenv(c compiler.Compiler, tf *taskfile.Taskfile, dir string) (*taskfile.Vars, error) { + if len(tf.Dotenv) == 0 { + return nil, nil + } + vars, err := c.GetTaskfileVariables() if err != nil { return nil, err