Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/volta-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ ctrlc = "3.1.3"
walkdir = "2.2.9"
volta-layout = { path = "../volta-layout" }
double-checked-cell = "2.0.2"
dunce = "1.0.0"

[target.'cfg(windows)'.dependencies]
winreg = "0.6.0"
3 changes: 2 additions & 1 deletion crates/volta-core/src/hook/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::command::create_command;
use crate::error::ErrorDetails;
use crate::tool::{NODE_DISTRO_ARCH, NODE_DISTRO_OS};
use cmdline_words_parser::StrExt;
use dunce::canonicalize;
use lazy_static::lazy_static;
use log::debug;
use semver::Version;
Expand Down Expand Up @@ -76,7 +77,7 @@ fn execute_binary(bin: &str, base_path: &Path, extra_arg: Option<String>) -> Fal
Some(word) => {
// Treat any path that starts with a './' or '../' as a relative path (using OS separator)
if word.starts_with(REL_PATH.as_str()) || word.starts_with(REL_PATH_PARENT.as_str()) {
base_path.join(word).canonicalize().with_context(|_| {
canonicalize(base_path.join(word)).with_context(|_| {
ErrorDetails::HookPathError {
command: String::from(word),
}
Expand Down
3 changes: 2 additions & 1 deletion crates/volta-core/src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::path::PathBuf;
use crate::error::ErrorDetails;
use cfg_if::cfg_if;
use double_checked_cell::DoubleCheckedCell;
use dunce::canonicalize;
use lazy_static::lazy_static;
use volta_fail::{Fallible, ResultExt};
use volta_layout::v1::{VoltaHome, VoltaInstall};
Expand Down Expand Up @@ -57,6 +58,6 @@ fn default_install_dir() -> Fallible<PathBuf> {
path.pop(); // Remove the executable name from the path
path
})
.and_then(|path| path.canonicalize())
.and_then(canonicalize)
.with_context(|_| ErrorDetails::NoInstallDir)
}
2 changes: 1 addition & 1 deletion crates/volta-core/src/tool/package/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ fn find_unpack_dir(in_dir: &Path) -> Fallible<PathBuf> {
// if there is only one directory, return that
if let [(entry, metadata)] = dirs.as_slice() {
if metadata.is_dir() {
return Ok(entry.path().to_path_buf());
return Ok(entry.path());
}
}
// there is more than just a single directory here, something is wrong
Expand Down
15 changes: 8 additions & 7 deletions crates/volta-core/src/tool/package/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::layout::volta_home;
use crate::session::Session;
use crate::shim;
use crate::style::{success_prefix, tool_version};
use dunce::canonicalize;
use log::info;
use semver::Version;
use volta_fail::{Fallible, ResultExt};
Expand All @@ -30,14 +31,14 @@ pub fn bin_full_path<P>(
where
P: AsRef<Path>,
{
// canonicalize because path is relative, and sometimes uses '.' char
volta_home()?
let raw_path = volta_home()?
.package_image_dir(package, &version.to_string())
.join(bin_path)
.canonicalize()
.with_context(|_| ErrorDetails::ExecutablePathError {
command: bin_name.to_string(),
})
.join(bin_path);

// canonicalize because path is relative, and sometimes uses '.' char
canonicalize(raw_path).with_context(|_| ErrorDetails::ExecutablePathError {
command: bin_name.to_string(),
})
}

/// Details required for fetching a 3rd-party Package
Expand Down
6 changes: 3 additions & 3 deletions src/command/list/plain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ pub(super) fn format(toolchain: &Toolchain) -> Option<String> {
Some(format!("{}\n{}", runtimes, package_managers))
}
(Some(runtimes), None, Some(packages)) => Some(format!("{}\n{}", runtimes, packages)),
(Some(runtimes), None, None) => Some(runtimes.to_string()),
(Some(runtimes), None, None) => Some(runtimes),
(None, Some(package_managers), Some(packages)) => {
Some(format!("{}\n{}", package_managers, packages))
}
(None, Some(package_managers), None) => Some(package_managers.to_string()),
(None, None, Some(packages)) => Some(packages.to_string()),
(None, Some(package_managers), None) => Some(package_managers),
(None, None, Some(packages)) => Some(packages),
(None, None, None) => None,
}
}
Expand Down