Fix clippy linting errors

feature/lookup-installed
trivernis 1 year ago
parent 8b4383aaf3
commit 621f599e32
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -62,7 +62,7 @@ map_os!(
);
#[cfg(not(target_os = "windows"))]
pub const ARCHIVE_TYPE: &'static str = "tar.gz";
pub const ARCHIVE_TYPE: &str = "tar.gz";
#[cfg(target_os = "windows")]
pub const ARCHIVE_TYPE: &'static str = "zip";

@ -106,7 +106,7 @@ impl ParseTomlError {
.map(|p| SourceSpan::new(p.into(), 0.into()));
Self {
src: NamedSource::new(file_name, src),
pos: abs_pos.into(),
pos: abs_pos,
caused_by,
}
}

@ -29,7 +29,10 @@ async fn main() -> Result<()> {
let args: Args = Args::parse();
match args.commmand {
args::Command::Version => Ok(print_version()),
args::Command::Version => {
print_version();
Ok(())
},
args::Command::Install(v) => install_version(v.version).await,
args::Command::Default(v) => set_default_version(v.version).await,
args::Command::Exec(args) => {
@ -56,18 +59,15 @@ pub async fn install_version(version: NodeVersion) -> Result<()> {
}
let repo = get_repository().await?;
if repo.is_installed(&version)? {
if !Confirm::new()
if repo.is_installed(&version)? && !Confirm::new()
.with_prompt(format!(
"The version {} is already installed. Reinstall?",
version.to_string().bold()
))
.default(false)
.interact()
.unwrap()
{
return Ok(());
}
.unwrap() {
return Ok(());
}
repo.install_version(&version).await?;
println!("Installed {}", version.to_string().bold());
@ -102,7 +102,7 @@ pub async fn exec(command: String, args: Vec<OsString>) -> Result<i32> {
let active_version = mapper.active_version();
if !mapper.repository().is_installed(active_version)? {
mapper.repository().install_version(&active_version).await?;
mapper.repository().install_version(active_version).await?;
}
let exit_status = mapper.exec(command, args).await?;

@ -56,7 +56,7 @@ impl NodeApp {
}
pub async fn map_node_bin(node_path: NodePath) -> Result<()> {
let mapped_app_names = get_applications(&*BIN_DIR)
let mapped_app_names = get_applications(&BIN_DIR)
.await?
.iter()
.map(NodeApp::name)

@ -120,7 +120,7 @@ impl Repository {
/// Returns the path for the given node version
pub fn get_version_path(&self, version: &NodeVersion) -> Result<Option<NodePath>> {
let info = self.lookup_version(&version)?;
let info = self.lookup_version(version)?;
let path = build_version_path(&info.version);
Ok(if path.exists() {
@ -158,11 +158,11 @@ impl Repository {
NodeVersion::LatestLts => self.versions.latest_lts(),
NodeVersion::Lts(lts) => self
.versions
.get_lts(&lts)
.get_lts(lts)
.ok_or_else(|| VersionError::unknown_version(lts.to_owned()))?,
NodeVersion::Req(req) => self
.versions
.get_fulfilling(&req)
.get_fulfilling(req)
.ok_or_else(|| VersionError::unfulfillable_version(req.to_owned()))?,
};
@ -176,7 +176,7 @@ impl Repository {
/// Installs a specified node version
pub async fn install_version(&self, version_req: &NodeVersion) -> Result<()> {
let info = self.lookup_version(&version_req)?;
let info = self.lookup_version(version_req)?;
let archive_path = self.download_version(&info.version).await?;
self.extract_archive(info, &archive_path)?;

Loading…
Cancel
Save