Skip to content

Commit 01bed51

Browse files
committed
fix: 修复windows环境使用sc时,获取执行输出信息失败问题
1 parent 0f141ef commit 01bed51

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

Cargo.toml

+14-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async-trait = "0.1.77"
2323
time = { version = "0.3.36", features = ["parsing", "macros"] }
2424
#rc4 = "0.1.0"
2525

26-
service-manager = "0.6.1"
26+
service-manager = "0.7"
2727

2828
reqwest = { version = "0.11", features = ["json"] }
2929

@@ -33,3 +33,16 @@ serde_yaml = "0.9.32"
3333

3434
anyhow = "1.0.86"
3535
thiserror = "1.0.62"
36+
37+
[build-dependencies]
38+
cargo-patch = "0.3"
39+
40+
[package.metadata.patch.service-manager]
41+
version = "0.7"
42+
patches = [
43+
"patches/sc.patch",
44+
"patches/service-manager-cargo.patch"
45+
]
46+
47+
[patch.crates-io]
48+
service-manager = { path = './target/patch/service-manager-0.7.1' }

build.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() {
2+
println!("cargo:rerun-if-changed=Cargo.toml");
3+
println!("cargo:rerun-if-changed=patches/");
4+
cargo_patch::patch().expect("Failed while patching");
5+
}

patches/sc.patch

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--- src/sc.rs
2+
+++ src/sc.rs
3+
@@ -283,11 +283,11 @@
4+
if output.status.success() {
5+
Ok(())
6+
} else {
7+
- let msg = String::from_utf8(output.stderr)
8+
+ use encoding::all::GBK;
9+
+ use encoding::{DecoderTrap, Encoding};
10+
+ let msg = GBK.decode(&*output.stderr, DecoderTrap::Replace)
11+
.ok()
12+
.filter(|s| !s.trim().is_empty())
13+
.or_else(|| {
14+
- String::from_utf8(output.stdout)
15+
+ GBK.decode(&*output.stdout, DecoderTrap::Replace)
16+
.ok()
17+
.filter(|s| !s.trim().is_empty())
18+
})

patches/service-manager-cargo.patch

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--- Cargo.toml
2+
+++ Cargo.toml
3+
@@ -25,11 +25,11 @@
4+
[dependencies.cfg-if]
5+
version = "1.0"
6+
+
7+
+[dependencies.encoding]
8+
+version = "0.2"

0 commit comments

Comments
 (0)