Pull Powershell profile

This commit is contained in:
Roey Darwish Dror
2018-08-23 22:08:04 +03:00
parent 79c2c77bbe
commit a049de31fb
3 changed files with 26 additions and 0 deletions

View File

@@ -41,6 +41,24 @@ impl Powershell {
}().is_ok()
}
pub fn profile(&self) -> Option<PathBuf> {
if let Some(powershell) = &self.path {
let result = || -> Result<PathBuf, failure::Error> {
let output = Command::new(powershell).args(&["-Command", "echo $profile"]).output()?;
output.status.check()?;
Ok(PathBuf::from(
String::from_utf8_lossy(&output.stdout).trim().to_string(),
))
}();
match result {
Err(e) => error!("Error getting Powershell profile: {}", e),
Ok(path) => return Some(path),
}
}
None
}
#[must_use]
pub fn update_modules(&self, terminal: &mut Terminal) -> Option<(&'static str, bool)> {
if let Some(powershell) = &self.path {