|
|
@ -1,7 +1,7 @@
|
|
|
|
use std::{ffi::OsString, str::FromStr};
|
|
|
|
use std::{ffi::OsString, str::FromStr};
|
|
|
|
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
use crate::{
|
|
|
|
config::ConfigAccess,
|
|
|
|
config::{ConfigAccess, ExecutableConfig},
|
|
|
|
consts::{BIN_DIR, CACHE_DIR, VERSION_FILE_PATH},
|
|
|
|
consts::{BIN_DIR, CACHE_DIR, VERSION_FILE_PATH},
|
|
|
|
error::VersionError,
|
|
|
|
error::VersionError,
|
|
|
|
mapper::Mapper,
|
|
|
|
mapper::Mapper,
|
|
|
@ -224,6 +224,35 @@ impl Nenv {
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Pins a given command
|
|
|
|
|
|
|
|
#[tracing::instrument(skip(self))]
|
|
|
|
|
|
|
|
pub async fn pin_command(&self, command: String, version: NodeVersion) -> Result<()> {
|
|
|
|
|
|
|
|
let mut config = self.config.get_mut().await;
|
|
|
|
|
|
|
|
config.bins.insert(
|
|
|
|
|
|
|
|
command.clone(),
|
|
|
|
|
|
|
|
ExecutableConfig {
|
|
|
|
|
|
|
|
node_version: version.clone(),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
println!(
|
|
|
|
|
|
|
|
"Pinned {} to {}",
|
|
|
|
|
|
|
|
command.bold(),
|
|
|
|
|
|
|
|
version.to_string().yellow().bold()
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Unpins a given command
|
|
|
|
|
|
|
|
#[tracing::instrument(skip(self))]
|
|
|
|
|
|
|
|
pub async fn unpin_command(&self, command: String) -> Result<()> {
|
|
|
|
|
|
|
|
let mut config = self.config.get_mut().await;
|
|
|
|
|
|
|
|
config.bins.remove(&command);
|
|
|
|
|
|
|
|
println!("Unpinned {}", command.bold());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Persits all changes made that aren't written to the disk yet
|
|
|
|
/// Persits all changes made that aren't written to the disk yet
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
pub async fn persist(&self) -> Result<()> {
|
|
|
|
pub async fn persist(&self) -> Result<()> {
|
|
|
|