|
|
@ -13,7 +13,7 @@ use crate::{
|
|
|
|
versioning::{SimpleVersion, VersionMetadata},
|
|
|
|
versioning::{SimpleVersion, VersionMetadata},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
use miette::{IntoDiagnostic, Result};
|
|
|
|
use miette::{Context, IntoDiagnostic, Result};
|
|
|
|
|
|
|
|
|
|
|
|
use self::{
|
|
|
|
use self::{
|
|
|
|
downloader::{versions::Versions, NodeDownloader},
|
|
|
|
downloader::{versions::Versions, NodeDownloader},
|
|
|
@ -175,6 +175,24 @@ impl Repository {
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Uninstalls the given node version by deleting the versions directory
|
|
|
|
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
|
|
|
|
pub async fn uninstall(&mut self, version: &NodeVersion) -> Result<()> {
|
|
|
|
|
|
|
|
let info = self.lookup_version(version).await?;
|
|
|
|
|
|
|
|
let version_dir = NODE_VERSIONS_DIR.join(info.version.to_string());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !version_dir.exists() {
|
|
|
|
|
|
|
|
return Err(VersionError::not_installed(version).into());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs::remove_dir_all(version_dir)
|
|
|
|
|
|
|
|
.await
|
|
|
|
|
|
|
|
.into_diagnostic()
|
|
|
|
|
|
|
|
.context("Deleting node version")?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Performs a lookup for the given node version
|
|
|
|
/// Performs a lookup for the given node version
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
pub async fn lookup_version(&mut self, version_req: &NodeVersion) -> Result<&VersionMetadata> {
|
|
|
|
pub async fn lookup_version(&mut self, version_req: &NodeVersion) -> Result<&VersionMetadata> {
|
|
|
|