Skip to content

Commit

Permalink
[skip ci] add derive to PackageFormat and change get_current to curre…
Browse files Browse the repository at this point in the history
…nt_format
  • Loading branch information
wiiznokes committed Dec 29, 2023
1 parent 6c76164 commit 2eb8936
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions crates/resource-resolver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod starting_binary;

use error::Result;

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PackageFormat {
/// When no format is used (`cargo run`)
None,
Expand All @@ -22,25 +23,23 @@ pub enum PackageFormat {
AppImage,
}

impl PackageFormat {
/// Get the current package format
pub fn get_current() -> Self {
// sync with PackageFormat::short_name function of packager crate
if cfg!(CARGO_PACKAGER_FORMAT = "app") {
PackageFormat::App
} else if cfg!(CARGO_PACKAGER_FORMAT = "dmg") {
PackageFormat::Dmg
} else if cfg!(CARGO_PACKAGER_FORMAT = "wix") {
PackageFormat::Wix
} else if cfg!(CARGO_PACKAGER_FORMAT = "nsis") {
PackageFormat::Nsis
} else if cfg!(CARGO_PACKAGER_FORMAT = "deb") {
PackageFormat::Deb
} else if cfg!(CARGO_PACKAGER_FORMAT = "appimage") {
PackageFormat::AppImage
} else {
PackageFormat::None
}
/// Get the current package format
pub fn current_format() -> PackageFormat {
// sync with PackageFormat::short_name function of packager crate
if cfg!(CARGO_PACKAGER_FORMAT = "app") {
PackageFormat::App
} else if cfg!(CARGO_PACKAGER_FORMAT = "dmg") {
PackageFormat::Dmg
} else if cfg!(CARGO_PACKAGER_FORMAT = "wix") {
PackageFormat::Wix
} else if cfg!(CARGO_PACKAGER_FORMAT = "nsis") {
PackageFormat::Nsis
} else if cfg!(CARGO_PACKAGER_FORMAT = "deb") {
PackageFormat::Deb
} else if cfg!(CARGO_PACKAGER_FORMAT = "appimage") {
PackageFormat::AppImage
} else {
PackageFormat::None
}
}

Expand Down

0 comments on commit 2eb8936

Please sign in to comment.