From 47f60477721681a117cbf905784ee5220100e68b Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Tue, 14 May 2024 11:03:44 -0700 Subject: [PATCH] Allow overriding tools/bazel path with BAZELISK_WRAPPER_PATH (#567) In some projects the tools/bazel path isn't practical. This allows users to override this path with the BAZELISK_WRAPPER_PATH env var / .bazeliskrc config option. --- core/core.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/core.go b/core/core.go index 429ae324..6ac3ba28 100644 --- a/core/core.go +++ b/core/core.go @@ -33,10 +33,11 @@ import ( ) const ( - bazelReal = "BAZEL_REAL" - skipWrapperEnv = "BAZELISK_SKIP_WRAPPER" - wrapperPath = "./tools/bazel" - maxDirLength = 255 + bazelReal = "BAZEL_REAL" + skipWrapperEnv = "BAZELISK_SKIP_WRAPPER" + defaultWrapperDirectory = "./tools" + defaultWrapperName = "bazel" + maxDirLength = 255 ) var ( @@ -502,6 +503,13 @@ func maybeDelegateToWrapperFromDir(bazel string, wd string, config config.Config return bazel } + wrapperPath := config.Get("BAZELISK_WRAPPER_DIRECTORY") + if wrapperPath == "" { + wrapperPath = filepath.Join(defaultWrapperDirectory, defaultWrapperName) + } else { + wrapperPath = filepath.Join(wrapperPath, defaultWrapperName) + } + root := ws.FindWorkspaceRoot(wd) wrapper := filepath.Join(root, wrapperPath) if stat, err := os.Stat(wrapper); err == nil && !stat.Mode().IsDir() && stat.Mode().Perm()&0111 != 0 {