From 33372b77f98e9ff050b8f4010f69e7641d8804c7 Mon Sep 17 00:00:00 2001 From: Kip Landergren Date: Wed, 6 Mar 2024 18:38:38 -0800 Subject: [PATCH] support MODULE.bazel file --- internal/ibazel/workspace/workspace.go | 4 ++++ internal/ibazel/workspace/workspace_test.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/internal/ibazel/workspace/workspace.go b/internal/ibazel/workspace/workspace.go index dbf91fc7..4a643b66 100644 --- a/internal/ibazel/workspace/workspace.go +++ b/internal/ibazel/workspace/workspace.go @@ -59,6 +59,10 @@ func (m *MainWorkspace) FindWorkspace() (string, error) { return path, nil } + if _, err := os.Stat(filepath.Join(path, "MODULE.bazel")); err == nil { + return path, nil + } + // If we've reached the root, then we know the cwd isn't within a workspace if path == volume { return "", errors.New("ibazel was not invoked from within a workspace\n") diff --git a/internal/ibazel/workspace/workspace_test.go b/internal/ibazel/workspace/workspace_test.go index 10931e34..983092aa 100644 --- a/internal/ibazel/workspace/workspace_test.go +++ b/internal/ibazel/workspace/workspace_test.go @@ -73,6 +73,14 @@ func TestAppleCaseInsensitivity(t *testing.T) { files: []string{}, err: false, }, + "MODULE.bazel": { + startingWD: "", + wantPath: "", + dirs: []string{}, + workspacePath: "/MODULE.bazel", + files: []string{}, + err: false, + }, } startDir, err := os.Getwd()