Skip to content

Conversation

amancevice
Copy link
Contributor

@amancevice amancevice commented Aug 21, 2021

This change allows users to include Taskfiles inside the home directory.

Paths beginning with the ~ character are expanded to absolute paths using os.UserHomeDir()

Example:

version: "3" includes: common: ~/.task/Taskfile.yml tasks: default: cmds: - task: common:task1 - task: common:task2 - echo 'Finished.'

This references #185 and resolves #539

Copy link
Member

@andreynering andreynering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @amancevice,

We already use execext.Expand(path) on other places to support ~. I'd prefer to use that here as well for consistency.

@amancevice
Copy link
Contributor Author

amancevice commented Sep 5, 2021

Thanks, @andreynering — change made & tested.

Copy link
Member

@andreynering andreynering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @amancevice,

Actually, there's no need for the whole else if you wrote. The point of Expand is that it takes care of everything for you. Something like this should be enough, before the if block:

path, err := execext.Expand(includedTask.Taskfile) if err != nil { return err } if filepath.IsAbs(path) { // ...
@amancevice
Copy link
Contributor Author

@andreynering I see, thanks for your patience — this is my first attempt at writing Go. Updated the PR to your recommendation

andreynering added a commit that referenced this pull request Sep 6, 2021
@andreynering andreynering merged commit 5ef1651 into go-task:master Sep 6, 2021
@andreynering
Copy link
Member

@amancevice No problem. Thanks a lot for your contribution! 🙂

@amancevice amancevice deleted the include-homedir branch October 7, 2023 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants