diff options
author | cbolgiano <cbolgiano625@gmail.com> | 2021-11-09 15:55:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 21:55:53 +0100 |
commit | 8d80d2ef062bdd9e8a7ae9d5ada7d465ae55c235 (patch) | |
tree | 652f197081b63eef560b1920c2307e86a6eb3714 | |
parent | 9c68d181e4609dccf0dcf967956eb753666d111b (diff) |
feat(python): Show value of PYENV_VERSION when present (#3144)
* 2872: Show value of PYENV_VERSION when present
* 2872: Run cargo fmt
-rw-r--r-- | src/modules/python.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/modules/python.rs b/src/modules/python.rs index 7ece718c9..4576db949 100644 --- a/src/modules/python.rs +++ b/src/modules/python.rs @@ -76,12 +76,19 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { } fn get_pyenv_version(context: &Context) -> Option<String> { - let version_name = context - .exec_cmd("pyenv", &["version-name"])? - .stdout - .trim() - .to_string(); - Some(version_name) + let mut version_name = context.get_env("PYENV_VERSION"); + + if version_name.is_none() { + version_name = Some( + context + .exec_cmd("pyenv", &["version-name"])? + .stdout + .trim() + .to_string(), + ) + } + + version_name } fn get_python_version(context: &Context, config: &PythonConfig) -> Option<String> { |