mirror of
https://github.com/denoland/deno.git
synced 2024-11-30 16:40:57 -05:00
fix(cli): output file handling in deno upgrade (#18994)
This commit is contained in:
parent
12767305cf
commit
443b840e5e
1 changed files with 24 additions and 18 deletions
|
@ -270,13 +270,15 @@ pub async fn upgrade(
|
||||||
let factory = CliFactory::from_flags(flags).await?;
|
let factory = CliFactory::from_flags(flags).await?;
|
||||||
let client = factory.http_client();
|
let client = factory.http_client();
|
||||||
let current_exe_path = std::env::current_exe()?;
|
let current_exe_path = std::env::current_exe()?;
|
||||||
let metadata = fs::metadata(¤t_exe_path)?;
|
let output_exe_path =
|
||||||
let permissions = metadata.permissions();
|
upgrade_flags.output.as_ref().unwrap_or(¤t_exe_path);
|
||||||
|
|
||||||
|
let permissions = if let Ok(metadata) = fs::metadata(output_exe_path) {
|
||||||
|
let permissions = metadata.permissions();
|
||||||
if permissions.readonly() {
|
if permissions.readonly() {
|
||||||
bail!(
|
bail!(
|
||||||
"You do not have write permission to {}",
|
"You do not have write permission to {}",
|
||||||
current_exe_path.display()
|
output_exe_path.display()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
@ -287,8 +289,12 @@ pub async fn upgrade(
|
||||||
"You don't have write permission to {} because it's owned by root.\n",
|
"You don't have write permission to {} because it's owned by root.\n",
|
||||||
"Consider updating deno through your package manager if its installed from it.\n",
|
"Consider updating deno through your package manager if its installed from it.\n",
|
||||||
"Otherwise run `deno upgrade` as root.",
|
"Otherwise run `deno upgrade` as root.",
|
||||||
), current_exe_path.display());
|
), output_exe_path.display());
|
||||||
}
|
}
|
||||||
|
permissions
|
||||||
|
} else {
|
||||||
|
fs::metadata(¤t_exe_path)?.permissions()
|
||||||
|
};
|
||||||
|
|
||||||
let install_version = match upgrade_flags.version {
|
let install_version = match upgrade_flags.version {
|
||||||
Some(passed_version) => {
|
Some(passed_version) => {
|
||||||
|
|
Loading…
Reference in a new issue