Skip to content

Commit

Permalink
Allow overriding tools/bazel path with BAZELISK_WRAPPER_PATH (#567)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
keith committed May 14, 2024
1 parent 2d2449e commit 47f6047
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 47f6047

Please sign in to comment.