2019-04-11 15:23:14 -07:00
|
|
|
use crate::common::*;
|
2018-03-05 13:21:35 -08:00
|
|
|
|
2019-04-11 15:23:14 -07:00
|
|
|
pub fn load_dotenv() -> RunResult<'static, BTreeMap<String, String>> {
|
2018-03-05 13:21:35 -08:00
|
|
|
match dotenv::dotenv_iter() {
|
|
|
|
Ok(iter) => {
|
2019-04-11 15:23:14 -07:00
|
|
|
let result: dotenv::Result<BTreeMap<String, String>> = iter.collect();
|
2018-12-08 14:29:41 -08:00
|
|
|
result.map_err(|dotenv_error| RuntimeError::Dotenv { dotenv_error })
|
2018-03-05 13:21:35 -08:00
|
|
|
}
|
2018-12-08 14:29:41 -08:00
|
|
|
Err(dotenv_error) => {
|
|
|
|
if dotenv_error.not_found() {
|
2019-04-11 15:23:14 -07:00
|
|
|
Ok(BTreeMap::new())
|
2018-12-08 14:29:41 -08:00
|
|
|
} else {
|
|
|
|
Err(RuntimeError::Dotenv { dotenv_error })
|
|
|
|
}
|
2018-03-05 13:21:35 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|