Skip to content

Commit

Permalink
Handle newlines for Bazel version detection
Browse files Browse the repository at this point in the history
  • Loading branch information
vogelsgesang committed Feb 1, 2025
1 parent cef1272 commit dff703b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/bazel_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ pub fn find_closest_version(available_version_strs: &[String], version_hint_str:
// Use the Bazelisk logic to figure out the Bazel version
pub fn determine_bazelisk_version(path: &Path) -> Option<String> {
if let Ok(version_str) = env::var("USE_BAZEL_VERSION") {
return Some(version_str);
return Some(version_str.trim().to_string());
}
let workspace_root = get_workspace_path(path)?;
if let Ok(bazeliskrc) = fs::read_to_string(workspace_root.join(".bazeliskrc")) {
for line in bazeliskrc.split('\n') {
if line.starts_with("USE_BAZEL_VERSION=") {
let version_str = &line.split_once('=').unwrap().1;
return Some(version_str.to_string());
return Some(version_str.trim().to_string());
}
}
None
} else if let Ok(bazelversion) = fs::read_to_string(workspace_root.join(".bazelversion")) {
return Some(bazelversion);
return Some(bazelversion.trim().to_string());
} else {
None
}
Expand Down

0 comments on commit dff703b

Please sign in to comment.