Rename .nurc to .nu

This commit is contained in:
Sam Hedin 2020-06-05 05:31:52 +02:00
parent da2751da54
commit 0ee54a3418
3 changed files with 31 additions and 4 deletions

View File

@ -58,7 +58,7 @@ impl NuConfig {
pub fn direnv_whitelist(&self) -> Option<Value> {
let vars = self.vars.lock();
if let Some(dirs) = vars.get("nurc_dirs") {
if let Some(dirs) = vars.get("nu_env_dirs") {
return Some(dirs.clone());
}
None

View File

@ -54,6 +54,32 @@ impl Environment {
}
}
pub fn add_env_force(&mut self, key: &str, value: &str) {
let value = UntaggedValue::string(value);
let new_envs = {
if let Some(Value {
value: UntaggedValue::Row(ref envs),
ref tag,
}) = self.environment_vars
{
let mut new_envs = envs.clone();
new_envs.insert_data_at_key(key, value.into_value(tag.clone()));
Value {
value: UntaggedValue::Row(new_envs),
tag: tag.clone(),
}
} else {
UntaggedValue::Row(indexmap! { key.into() => value.into_untagged_value() }.into())
.into_untagged_value()
}
};
self.environment_vars = Some(new_envs);
}
pub fn morph<T: Conf>(&mut self, configuration: &T) {
self.environment_vars = configuration.env();
self.path_vars = configuration.path();
@ -77,6 +103,8 @@ impl Env for Environment {
None
}
fn add_env(&mut self, key: &str, value: &str) {
let value = UntaggedValue::string(value);

View File

@ -88,7 +88,7 @@ impl EnvironmentSyncer {
while working_dir.is_some() {
if working_dir.unwrap() == dir.as_path() {
dir.push(".nurc");
dir.push(".nu");
let mut file = File::open(dir.as_path())?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
@ -97,7 +97,7 @@ impl EnvironmentSyncer {
let nurc_vars = toml_doc.get("env").unwrap().as_table().unwrap();
nurc_vars.iter().for_each(|(k, v)| {
environment.add_env(&k, &v.as_str().unwrap().to_string());
environment.add_env_force(&k, &v.as_str().unwrap().to_string());
});
break;
} else {
@ -105,7 +105,6 @@ impl EnvironmentSyncer {
}
}
}
environment.add_env("envtest", "I overwrote successfully");
Ok(())
}