Make repo more relocatable on developer's workstation.

This commit is contained in:
jregan
2019-11-10 10:42:54 -08:00
parent 6df4efd145
commit 02c0c2692f
3 changed files with 24 additions and 4 deletions

View File

@@ -30,11 +30,31 @@ type Compiler struct {
objRoot string
}
// DefaultSrcRoot guesses where the user
// DeterminePluginSrcRoot guesses where the user
// has her ${g}/${v}/$lower(${k})/${k}.go files.
func DefaultSrcRoot(fSys filesys.FileSystem) (string, error) {
func DeterminePluginSrcRoot(fSys filesys.FileSystem) (string, error) {
return konfig.FirstDirThatExistsElseError(
"source directory", fSys, []konfig.NotedFunc{
{
Note: "relative to unit test",
F: func() string {
return filepath.Clean(
filepath.Join(
os.Getenv("PWD"),
"..", "..", "..", "..",
konfig.RelPluginHome))
},
},
{
Note: "relative to api package",
F: func() string {
return filepath.Clean(
filepath.Join(
os.Getenv("PWD"),
"..", "..", "..",
konfig.RelPluginHome))
},
},
{
Note: "old style $GOPATH",
F: func() string {

View File

@@ -19,7 +19,7 @@ func TestCompiler(t *testing.T) {
if err != nil {
t.Errorf("failed to make temp dir: %v", err)
}
srcRoot, err := DefaultSrcRoot(filesys.MakeFsOnDisk())
srcRoot, err := DeterminePluginSrcRoot(filesys.MakeFsOnDisk())
if err != nil {
t.Error(err)
}

View File

@@ -76,7 +76,7 @@ func (x *PluginTestEnv) makeCompiler() *compiler.Compiler {
if err != nil {
x.t.Error(err)
}
srcRoot, err := compiler.DefaultSrcRoot(filesys.MakeFsOnDisk())
srcRoot, err := compiler.DeterminePluginSrcRoot(filesys.MakeFsOnDisk())
if err != nil {
x.t.Error(err)
}