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

Traverse upwards to find ./magefiles directory #513

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

morganhein
Copy link

@morganhein morganhein commented Oct 16, 2024

This is a follow up from the other PR that has stalled. (#290)

I am using mage in a monorepo, with many layers of folders that may contain magefiles. It's been a major improvement working with this repo when mage walks up the tree to find the closest magefiles folder.

This PR causes the following affects:

  1. By default, it searches for a magefiles folder within the current directory
  2. If not found, it begins walking up the tree to find the folder
  3. If a .git folder is detected, it stops. This is based on the assumption that many magefiles probably should be scope to their git repository
  4. If the root is encountered, it also stops.
  5. You can disable this behavior by passing -no-traverse or setting MAGEFILE_NO_TRAVERSE as an environment variable

I can see an argument for some sort of .magebuild or .mageroot file that also can be used to indicate traversal stopping.

I did not update the website. I'm open to that, however wanted to get some opinions on this before I work on it much further.

Thanks!

@DavidGamba
Copy link

DavidGamba commented Oct 16, 2024

In my implementation of this for a similar tool, I have a case for when the current folder is the magefiles folder. I suppose you just walk up and find it but I though of it as an edge case that returns '.' rather than doing some work to make it relative.

https://github.com/DavidGamba/dgtools/blob/master/bake/build.go#L64

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.

2 participants