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
26 changes: 17 additions & 9 deletions src-tauri/src/services/deno.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::types::DenoStatus;
use crate::utils::{find_system_binary, unix_system_binary_dirs, CommandExt};
#[cfg(not(windows))]
use crate::utils::unix_system_binary_dirs;
use crate::utils::{find_system_binary, CommandExt};
use std::path::PathBuf;
use std::process::Stdio;
use tauri::{AppHandle, Manager};
Expand All @@ -11,14 +13,20 @@ fn get_system_deno_path() -> Option<PathBuf> {
#[cfg(not(windows))]
let binary_name = "deno";

let mut fallback_dirs = Vec::new();

#[cfg(not(windows))]
{
let home = std::env::var("HOME").unwrap_or_default();
fallback_dirs.push(PathBuf::from(home).join(".deno/bin"));
fallback_dirs.extend(unix_system_binary_dirs());
}
let fallback_dirs = {
#[cfg(windows)]
{
Vec::new()
}
#[cfg(not(windows))]
{
let mut dirs = Vec::new();
let home = std::env::var("HOME").unwrap_or_default();
dirs.push(PathBuf::from(home).join(".deno/bin"));
dirs.extend(unix_system_binary_dirs());
dirs
}
};

find_system_binary(binary_name, &fallback_dirs)
}
Expand Down
3 changes: 1 addition & 2 deletions src-tauri/src/utils/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub trait CommandExt {
impl CommandExt for Command {
#[cfg(windows)]
fn hide_window(&mut self) -> &mut Self {
use std::os::windows::process::CommandExt as WinCommandExt;
self.creation_flags(CREATE_NO_WINDOW);
self
}
Expand All @@ -33,7 +32,7 @@ impl CommandExt for Command {
impl CommandExt for std::process::Command {
#[cfg(windows)]
fn hide_window(&mut self) -> &mut Self {
use std::os::windows::process::CommandExt as WinCommandExt;
use std::os::windows::process::CommandExt as _;
self.creation_flags(CREATE_NO_WINDOW);
self
}
Expand Down
12 changes: 10 additions & 2 deletions src-tauri/src/utils/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,19 @@ pub fn unix_system_binary_dirs() -> Vec<PathBuf> {
}
#[cfg(not(windows))]
{
vec![
let mut dirs = Vec::new();

if let Some(home) = std::env::var_os("HOME") {
dirs.push(PathBuf::from(home).join(".local").join("bin"));
}

dirs.extend([
PathBuf::from("/opt/homebrew/bin"),
PathBuf::from("/usr/local/bin"),
PathBuf::from("/usr/bin"),
]
]);

dirs
}
}

Expand Down
Loading