aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xtask/src/cmd.rs8
-rw-r--r--xtask/src/install.rs25
-rw-r--r--xtask/src/pre_commit.rs2
3 files changed, 16 insertions, 19 deletions
diff --git a/xtask/src/cmd.rs b/xtask/src/cmd.rs
index 2027f4893..8e08a929b 100644
--- a/xtask/src/cmd.rs
+++ b/xtask/src/cmd.rs
@@ -18,7 +18,7 @@ impl Cmd<'_> {
18 run(self.unix, self.work_dir) 18 run(self.unix, self.work_dir)
19 } 19 }
20 } 20 }
21 pub fn run_with_output(self) -> Result<Output> { 21 pub fn run_with_output(self) -> Result<String> {
22 if cfg!(windows) { 22 if cfg!(windows) {
23 run_with_output(self.windows, self.work_dir) 23 run_with_output(self.windows, self.work_dir)
24 } else { 24 } else {
@@ -34,8 +34,10 @@ pub fn run(cmdline: &str, dir: &str) -> Result<()> {
34 .map(|_| ()) 34 .map(|_| ())
35} 35}
36 36
37pub fn run_with_output(cmdline: &str, dir: &str) -> Result<Output> { 37pub fn run_with_output(cmdline: &str, dir: &str) -> Result<String> {
38 do_run(cmdline, dir, &mut |_| {}) 38 let output = do_run(cmdline, dir, &mut |_| {})?;
39 let stdout = String::from_utf8(output.stdout)?;
40 Ok(stdout)
39} 41}
40 42
41fn do_run(cmdline: &str, dir: &str, f: &mut dyn FnMut(&mut Command)) -> Result<Output> { 43fn do_run(cmdline: &str, dir: &str, f: &mut dyn FnMut(&mut Command)) -> Result<Output> {
diff --git a/xtask/src/install.rs b/xtask/src/install.rs
index 0e7cda3fa..99e1eddb1 100644
--- a/xtask/src/install.rs
+++ b/xtask/src/install.rs
@@ -127,15 +127,12 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> {
127 } 127 }
128 .run()?; 128 .run()?;
129 129
130 let installed_extensions = { 130 let installed_extensions = Cmd {
131 let output = Cmd { 131 unix: &format!(r"{} --list-extensions", code_binary),
132 unix: &format!(r"{} --list-extensions", code_binary), 132 windows: &format!(r"cmd.exe /c {}.cmd --list-extensions", code_binary),
133 windows: &format!(r"cmd.exe /c {}.cmd --list-extensions", code_binary), 133 work_dir: ".",
134 work_dir: ".", 134 }
135 } 135 .run_with_output()?;
136 .run_with_output()?;
137 String::from_utf8(output.stdout)?
138 };
139 136
140 if !installed_extensions.contains("rust-analyzer") { 137 if !installed_extensions.contains("rust-analyzer") {
141 anyhow::bail!( 138 anyhow::bail!(
@@ -161,12 +158,10 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> {
161 158
162fn install_server(opts: ServerOpt) -> Result<()> { 159fn install_server(opts: ServerOpt) -> Result<()> {
163 let mut old_rust = false; 160 let mut old_rust = false;
164 if let Ok(output) = run_with_output("cargo --version", ".") { 161 if let Ok(stdout) = run_with_output("cargo --version", ".") {
165 if let Ok(stdout) = String::from_utf8(output.stdout) { 162 println!("{}", stdout);
166 println!("{}", stdout); 163 if !check_version(&stdout, REQUIRED_RUST_VERSION) {
167 if !check_version(&stdout, REQUIRED_RUST_VERSION) { 164 old_rust = true;
168 old_rust = true;
169 }
170 } 165 }
171 } 166 }
172 167
diff --git a/xtask/src/pre_commit.rs b/xtask/src/pre_commit.rs
index 88e868ca6..1533f64dc 100644
--- a/xtask/src/pre_commit.rs
+++ b/xtask/src/pre_commit.rs
@@ -14,7 +14,7 @@ pub fn run_hook() -> Result<()> {
14 let diff = run_with_output("git diff --diff-filter=MAR --name-only --cached", ".")?; 14 let diff = run_with_output("git diff --diff-filter=MAR --name-only --cached", ".")?;
15 15
16 let root = project_root(); 16 let root = project_root();
17 for line in String::from_utf8(diff.stdout)?.lines() { 17 for line in diff.lines() {
18 run(&format!("git update-index --add {}", root.join(line).to_string_lossy()), ".")?; 18 run(&format!("git update-index --add {}", root.join(line).to_string_lossy()), ".")?;
19 } 19 }
20 20