feat(single-instance): Add semver compatibility check for Windows and Linux (#502)
* added semver compatibility check for Windows and Linux * fixed formatting * put semver feature behind a feature flag * remove semver from root manifest * linux compile error * docs: Add mention for semver feature in readme --------- Co-authored-by: FabianLars <fabianlars@fabianlars.de>pull/1188/head
parent
57e979adaf
commit
4210cf316a
@ -0,0 +1,17 @@
|
||||
#![cfg(feature = "semver")]
|
||||
|
||||
/// Takes a version and spits out a String with trailing _x, thus only considering the digits
|
||||
/// relevant regarding semver compatibility
|
||||
pub fn semver_compat_string(version: semver::Version) -> String {
|
||||
// for pre-release always treat each version separately
|
||||
if !version.pre.is_empty() {
|
||||
return version.to_string().replace(['.', '-'], "_");
|
||||
}
|
||||
match version.major {
|
||||
0 => match version.minor {
|
||||
0 => format!("0_0_{}", version.patch),
|
||||
_ => format!("0_{}_x", version.minor),
|
||||
},
|
||||
_ => format!("{}_x_x", version.major),
|
||||
}
|
||||
}
|
Loading…
Reference in new issue