-
Notifications
You must be signed in to change notification settings - Fork 1k
Simple approach to finding project root dir #6
Conversation
Project root inference is done by searching for an appropriately-named file (currently manifest.json). Search should generally proceed from the cwd upwards towards root.
Looks good but I think at some point we should stop looking upwards once we reach the $ export GOPATH=$HOME/go
$ ls $HOME
go
manifest.json
$ cd $GOPATH/src/github.com/foo/bar
$ ls
main.go ^^ Assuming there isn't a |
Ah! good call. That also implies another check, I think - that the tool can't work operate at all if it's off-GOPATH. I don't know how much I like that, but it seems necessary to include if we're going to limit the upwards search path to GOPATH. If we go that far, it also might suggest that, in #7, we pick the GOPATH used for the cachedir based on the GOPATH in which we're currently situated, rather than just grabbing the first one. (Side note - I do wish we were moving further from GOPATH rather than binding more tightly, but this is clearly the path of least resistance rn) |
this is why I included"at some point". Basically I think this is fine for now as long as we are aware of the caveat that this can escape upwards to a location we didn't intend. |
Another possible way to handle this w/o involving |
fair nuff 😄
yeah, i gave some thought to that. i decided to leave that as a separate path, possibly to be used by i figure this does best with KISS, then figuring out adaptive strategies as we run into issues. |
True. I don't think any approach is "fool" proof. But $HOME/.git and $HOME/manfiest.json is less likely. Anyway, this discussion is likely premature. |
Basically, walk up the dir tree, looking for a manifest.