summaryrefslogtreecommitdiff
path: root/cli/tools
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tools')
-rw-r--r--cli/tools/compile.rs32
-rw-r--r--cli/tools/installer.rs2
-rw-r--r--cli/tools/upgrade.rs11
-rw-r--r--cli/tools/vendor/mod.rs2
4 files changed, 26 insertions, 21 deletions
diff --git a/cli/tools/compile.rs b/cli/tools/compile.rs
index ed8f07542..2825c92c7 100644
--- a/cli/tools/compile.rs
+++ b/cli/tools/compile.rs
@@ -4,7 +4,6 @@ use crate::args::CompileFlags;
use crate::args::Flags;
use crate::factory::CliFactory;
use crate::standalone::is_standalone_binary;
-use crate::util::path::path_has_trailing_slash;
use deno_core::anyhow::bail;
use deno_core::anyhow::Context;
use deno_core::error::generic_error;
@@ -174,31 +173,34 @@ async fn resolve_compile_executable_output_path(
let module_specifier =
resolve_url_or_path(&compile_flags.source_file, current_dir)?;
- let mut output = compile_flags.output.clone();
-
- if let Some(out) = output.as_ref() {
- if path_has_trailing_slash(out) {
+ let output_flag = compile_flags.output.clone();
+ let mut output_path = if let Some(out) = output_flag.as_ref() {
+ let mut out_path = PathBuf::from(out);
+ if out.ends_with('/') || out.ends_with('\\') {
if let Some(infer_file_name) = infer_name_from_url(&module_specifier)
.await
.map(PathBuf::from)
{
- output = Some(out.join(infer_file_name));
+ out_path = out_path.join(infer_file_name);
}
} else {
- output = Some(out.to_path_buf());
+ out_path = out_path.to_path_buf();
}
- }
+ Some(out_path)
+ } else {
+ None
+ };
- if output.is_none() {
- output = infer_name_from_url(&module_specifier)
+ if output_flag.is_none() {
+ output_path = infer_name_from_url(&module_specifier)
.await
.map(PathBuf::from)
}
- output.ok_or_else(|| generic_error(
+ output_path.ok_or_else(|| generic_error(
"An executable name was not provided. One could not be inferred from the URL. Aborting.",
- )).map(|output| {
- get_os_specific_filepath(output, &compile_flags.target)
+ )).map(|output_path| {
+ get_os_specific_filepath(output_path, &compile_flags.target)
})
}
@@ -231,7 +233,7 @@ mod test {
let path = resolve_compile_executable_output_path(
&CompileFlags {
source_file: "mod.ts".to_string(),
- output: Some(PathBuf::from("./file")),
+ output: Some(String::from("./file")),
args: Vec::new(),
target: Some("x86_64-unknown-linux-gnu".to_string()),
no_terminal: false,
@@ -253,7 +255,7 @@ mod test {
let path = resolve_compile_executable_output_path(
&CompileFlags {
source_file: "mod.ts".to_string(),
- output: Some(PathBuf::from("./file")),
+ output: Some(String::from("./file")),
args: Vec::new(),
target: Some("x86_64-pc-windows-msvc".to_string()),
include: vec![],
diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs
index 1b1b6f30c..ea4b5ff48 100644
--- a/cli/tools/installer.rs
+++ b/cli/tools/installer.rs
@@ -455,7 +455,7 @@ async fn resolve_shim_data(
extra_files.push((
copy_path,
fs::read_to_string(lock_path)
- .with_context(|| format!("error reading {}", lock_path.display()))?,
+ .with_context(|| format!("error reading {}", lock_path))?,
));
} else {
// Provide an empty lockfile so that this overwrites any existing lockfile
diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs
index 86a271c1f..6bb4606d3 100644
--- a/cli/tools/upgrade.rs
+++ b/cli/tools/upgrade.rs
@@ -379,8 +379,11 @@ pub async fn upgrade(
let factory = CliFactory::from_flags(flags)?;
let client = factory.http_client();
let current_exe_path = std::env::current_exe()?;
+ let full_path_output_flag = upgrade_flags
+ .output
+ .map(|output| factory.cli_options().initial_cwd().join(output));
let output_exe_path =
- upgrade_flags.output.as_ref().unwrap_or(&current_exe_path);
+ full_path_output_flag.as_ref().unwrap_or(&current_exe_path);
let permissions = if let Ok(metadata) = fs::metadata(output_exe_path) {
let permissions = metadata.permissions();
@@ -430,7 +433,7 @@ pub async fn upgrade(
};
if !upgrade_flags.force
- && upgrade_flags.output.is_none()
+ && full_path_output_flag.is_none()
&& current_is_passed
{
log::info!("Version {} is already installed", crate::version::deno());
@@ -464,7 +467,7 @@ pub async fn upgrade(
};
if !upgrade_flags.force
- && upgrade_flags.output.is_none()
+ && full_path_output_flag.is_none()
&& current_is_most_recent
{
log::info!(
@@ -520,7 +523,7 @@ pub async fn upgrade(
}
} else {
let output_exe_path =
- upgrade_flags.output.as_ref().unwrap_or(&current_exe_path);
+ full_path_output_flag.as_ref().unwrap_or(&current_exe_path);
let output_result = if *output_exe_path == current_exe_path {
replace_exe(&new_exe_path, output_exe_path)
} else {
diff --git a/cli/tools/vendor/mod.rs b/cli/tools/vendor/mod.rs
index 975cf08f1..2e01d1963 100644
--- a/cli/tools/vendor/mod.rs
+++ b/cli/tools/vendor/mod.rs
@@ -40,7 +40,7 @@ pub async fn vendor(
) -> Result<(), AnyError> {
let mut cli_options = CliOptions::from_flags(flags)?;
let raw_output_dir = match &vendor_flags.output_path {
- Some(output_path) => output_path.to_owned(),
+ Some(output_path) => PathBuf::from(output_path).to_owned(),
None => PathBuf::from("vendor/"),
};
let output_dir = resolve_from_cwd(&raw_output_dir)?;