Skip to content

Commit

Permalink
Prefer BAZELISK_HOME with OS postfix
Browse files Browse the repository at this point in the history
  • Loading branch information
mzapotoczny authored and Michal Zapotoczny committed Jun 14, 2023
1 parent d0e93d2 commit fa44418
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ The following variables can be set:
- `BAZELISK_BASE_URL`
- `BAZELISK_CLEAN`
- `BAZELISK_GITHUB_TOKEN`
- `BAZELISK_HOME_DARWIN`
- `BAZELISK_HOME_LINUX`
- `BAZELISK_HOME_WINDOWS`
- `BAZELISK_HOME`
- `BAZELISK_INCOMPATIBLE_FLAGS`
- `BAZELISK_SHUTDOWN`
Expand All @@ -195,6 +198,8 @@ Configuration variables are evaluated with precedence order. The preferred value
* Variables defined in the workspace root `.bazeliskrc`
* Variables defined in the user home `.bazeliskrc`

Additionally, the bazelisk home directory is also evaluated in precedence order. The preffered value is OS-specific e.g. `BAZELISK_HOME_LINUX`, then we fall back to `BAZELISK_HOME`.

## Requirements

For ease of use, the Python version of Bazelisk is written to work with Python 2.7 and 3.x and only uses modules provided by the standard library.
Expand Down
5 changes: 4 additions & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ func RunBazeliskWithArgsFunc(argsFunc ArgsFunc, repos *Repositories) (int, error
func RunBazeliskWithArgsFuncAndConfig(argsFunc ArgsFunc, repos *Repositories, config config.Config) (int, error) {
httputil.UserAgent = getUserAgent(config)

bazeliskHome := config.Get("BAZELISK_HOME")
bazeliskHome := config.Get("BAZELISK_HOME_" + strings.ToUpper(runtime.GOOS))
if len(bazeliskHome) == 0 {
bazeliskHome = config.Get("BAZELISK_HOME")
}
if len(bazeliskHome) == 0 {
userCacheDir, err := os.UserCacheDir()
if err != nil {
Expand Down

0 comments on commit fa44418

Please sign in to comment.