2019-04-11 15:23:14 -07:00
|
|
|
use crate::common::*;
|
2017-11-16 23:30:08 -08:00
|
|
|
|
2019-09-21 15:35:03 -07:00
|
|
|
pub(crate) trait CommandExt {
|
2017-11-16 23:30:08 -08:00
|
|
|
fn export_environment_variables<'a>(
|
|
|
|
&mut self,
|
2019-11-07 10:55:15 -08:00
|
|
|
scope: &BTreeMap<&'a str, (bool, String)>,
|
2019-04-11 15:23:14 -07:00
|
|
|
dotenv: &BTreeMap<String, String>,
|
2017-11-17 17:28:06 -08:00
|
|
|
) -> RunResult<'a, ()>;
|
2017-11-16 23:30:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl CommandExt for Command {
|
|
|
|
fn export_environment_variables<'a>(
|
|
|
|
&mut self,
|
2019-11-07 10:55:15 -08:00
|
|
|
scope: &BTreeMap<&'a str, (bool, String)>,
|
2019-04-11 15:23:14 -07:00
|
|
|
dotenv: &BTreeMap<String, String>,
|
2017-11-17 17:28:06 -08:00
|
|
|
) -> RunResult<'a, ()> {
|
2018-03-05 13:21:35 -08:00
|
|
|
for (name, value) in dotenv {
|
|
|
|
self.env(name, value);
|
|
|
|
}
|
2019-11-07 10:55:15 -08:00
|
|
|
|
|
|
|
for (name, (export, value)) in scope {
|
|
|
|
if *export {
|
2017-11-16 23:30:08 -08:00
|
|
|
self.env(name, value);
|
|
|
|
}
|
|
|
|
}
|
2019-11-07 10:55:15 -08:00
|
|
|
|
2017-11-16 23:30:08 -08:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|