Skip to content

Commit

Permalink
fix: Getting npm perfix path is more reliable.
Browse files Browse the repository at this point in the history
Signed-off-by: The1111mp <[email protected]>
  • Loading branch information
1111mp committed Oct 12, 2023
1 parent 5e214c0 commit 7cd0bd7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/run/npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ fn get_npm_perfix() -> String {
let mut perfix = String::from("");
for line in lines {
let cur_line = line.unwrap();
if cur_line.contains(".nvmd") {
if PathBuf::from(&cur_line).is_dir() {
perfix = cur_line;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/run/nvmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ fn command_for_list() -> Result<(), Error> {
for item in ls_result.items {
match item.get(&DirEntryAttr::Name) {
Some(DirEntryValue::String(version)) => {
if is_uninstall_version(version) {
versions.push(version.clone());
if is_valid_version(version) {
versions.push(version.to_string());
}
}
_ => {}
Expand Down Expand Up @@ -128,7 +128,7 @@ fn command_for_use_global(ver: &String) {
version.remove(0);
}

if !is_uninstall_version(&version) {
if !is_valid_version(&version) {
eprintln!("nvm-desktop: v{} has not been installed", &version);
return;
}
Expand All @@ -152,7 +152,7 @@ fn command_for_use_project(ver: &String) {
version.remove(0);
}

if !is_uninstall_version(&version) {
if !is_valid_version(&version) {
eprintln!("nvm-desktop: v{} has not been installed", &version);
return;
}
Expand Down Expand Up @@ -241,7 +241,7 @@ fn command_for_which(ver: &String) {
}
}

fn is_uninstall_version(version: &String) -> bool {
fn is_valid_version(version: &String) -> bool {
let mut version_path = NVMD_PATH.clone();
version_path.push("versions");
version_path.push(&version);
Expand Down

0 comments on commit 7cd0bd7

Please sign in to comment.