mirror of
https://github.com/nushell/nushell.git
synced 2025-04-29 23:54:26 +02:00
Rename .nurc to .nu
This commit is contained in:
parent
da2751da54
commit
0ee54a3418
@ -58,7 +58,7 @@ impl NuConfig {
|
|||||||
|
|
||||||
pub fn direnv_whitelist(&self) -> Option<Value> {
|
pub fn direnv_whitelist(&self) -> Option<Value> {
|
||||||
let vars = self.vars.lock();
|
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());
|
return Some(dirs.clone());
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
28
crates/nu-cli/src/env/environment.rs
vendored
28
crates/nu-cli/src/env/environment.rs
vendored
@ -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) {
|
pub fn morph<T: Conf>(&mut self, configuration: &T) {
|
||||||
self.environment_vars = configuration.env();
|
self.environment_vars = configuration.env();
|
||||||
self.path_vars = configuration.path();
|
self.path_vars = configuration.path();
|
||||||
@ -77,6 +103,8 @@ impl Env for Environment {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn add_env(&mut self, key: &str, value: &str) {
|
fn add_env(&mut self, key: &str, value: &str) {
|
||||||
let value = UntaggedValue::string(value);
|
let value = UntaggedValue::string(value);
|
||||||
|
|
||||||
|
5
crates/nu-cli/src/env/environment_syncer.rs
vendored
5
crates/nu-cli/src/env/environment_syncer.rs
vendored
@ -88,7 +88,7 @@ impl EnvironmentSyncer {
|
|||||||
|
|
||||||
while working_dir.is_some() {
|
while working_dir.is_some() {
|
||||||
if working_dir.unwrap() == dir.as_path() {
|
if working_dir.unwrap() == dir.as_path() {
|
||||||
dir.push(".nurc");
|
dir.push(".nu");
|
||||||
let mut file = File::open(dir.as_path())?;
|
let mut file = File::open(dir.as_path())?;
|
||||||
let mut contents = String::new();
|
let mut contents = String::new();
|
||||||
file.read_to_string(&mut contents)?;
|
file.read_to_string(&mut contents)?;
|
||||||
@ -97,7 +97,7 @@ impl EnvironmentSyncer {
|
|||||||
let nurc_vars = toml_doc.get("env").unwrap().as_table().unwrap();
|
let nurc_vars = toml_doc.get("env").unwrap().as_table().unwrap();
|
||||||
|
|
||||||
nurc_vars.iter().for_each(|(k, v)| {
|
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;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -105,7 +105,6 @@ impl EnvironmentSyncer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
environment.add_env("envtest", "I overwrote successfully");
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user