Skip to content

Commit

Permalink
derive package name from branch name when patching
Browse files Browse the repository at this point in the history
  • Loading branch information
maddymeows committed Jan 16, 2025
1 parent 7a8ec0b commit fb64b2f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
5 changes: 3 additions & 2 deletions crates/libmoonlight/src/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ impl Installer {

"linux" => {
let home = std::env::var("HOME").unwrap();
let local_share = std::env::var_os("MOONLIGHT_DISCORD_SHARE_LINUX").map(PathBuf::from)
let local_share = std::env::var_os("MOONLIGHT_DISCORD_SHARE_LINUX")
.map(PathBuf::from)
.unwrap_or(PathBuf::from(home).join(".local/share"));

let dirs = vec![
Expand Down Expand Up @@ -266,7 +267,7 @@ impl Installer {
std::fs::create_dir(app_dir.join("app"))?;

let json = serde_json::json!({
"name": "discord",
"name": install.branch.dashed_name(),
"main": "./injector.js",
"private": true
});
Expand Down
19 changes: 16 additions & 3 deletions crates/libmoonlight/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,26 @@ impl Branch {
get_moonlight_dir().join(format!("{}.json", self.to_string().to_lowercase()))
}

pub fn kill_discord(&self) {
let name = match self {
pub fn name(&self) -> &'static str {
match self {
Self::Stable => "Discord",
Self::PTB => "DiscordPTB",
Self::Canary => "DiscordCanary",
Self::Development => "DiscordDevelopment",
};
}
}

pub fn dashed_name(&self) -> &'static str {
match self {
Self::Stable => "discord",
Self::PTB => "discord-ptb",
Self::Canary => "discord-canary",
Self::Development => "discord-development",
}
}

pub fn kill_discord(&self) {
let name = self.name();

match std::env::consts::OS {
"windows" => {
Expand Down

0 comments on commit fb64b2f

Please sign in to comment.