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

fix: ignore empty dotfile file names #866

Merged
merged 1 commit into from
Sep 8, 2022

Conversation

pd93
Copy link
Member

@pd93 pd93 commented Sep 8, 2022

This PR fixes #858 - A bug (introduced in f45dd11) that causes an "is a directory" error when a taskfile contains a dotfiles key with unresolved variable.

The bug exists because the new e.setCurrentDir() function is setting e.Dir to the taskfile's root directory where it was previously "". When this variable was empty and the given dotfile was also empty, os.Stat would have returned an os.ErrNotExist and the loop would have continued. However, now that e.Dir is set to the taskfile directory, this os.Stat() check passes (as the directory exists) and the godotenv.Read() function errors causing the program to fail.

This fix simply checks if each value in the list of dotfiles is empty (not set) and continues if it is. This allows users to continue using the behaviour described in #858 where they could conditionally set environment variables via the dotfiles key.

@andreynering
Copy link
Member

Thanks @pd93!

@andreynering andreynering merged commit c79ea5a into go-task:master Sep 8, 2022
@pd93 pd93 deleted the fix-read-dotenv branch September 9, 2022 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting "is a directory" for Task v3.15.0
2 participants