diff options
Diffstat (limited to 'xtask/src')
-rw-r--r-- | xtask/src/install.rs | 18 | ||||
-rw-r--r-- | xtask/src/not_bash.rs | 30 |
2 files changed, 8 insertions, 40 deletions
diff --git a/xtask/src/install.rs b/xtask/src/install.rs index 00bbabce4..91426377f 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs | |||
@@ -4,7 +4,7 @@ use std::{env, path::PathBuf, str}; | |||
4 | 4 | ||
5 | use anyhow::{bail, format_err, Context, Result}; | 5 | use anyhow::{bail, format_err, Context, Result}; |
6 | 6 | ||
7 | use crate::not_bash::{ls, pushd, rm, run}; | 7 | use crate::not_bash::{pushd, run}; |
8 | 8 | ||
9 | // Latest stable, feel free to send a PR if this lags behind. | 9 | // Latest stable, feel free to send a PR if this lags behind. |
10 | const REQUIRED_RUST_VERSION: u32 = 41; | 10 | const REQUIRED_RUST_VERSION: u32 = 41; |
@@ -99,28 +99,20 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { | |||
99 | run!("npm --version").context("`npm` is required to build the VS Code plugin")?; | 99 | run!("npm --version").context("`npm` is required to build the VS Code plugin")?; |
100 | run!("npm install")?; | 100 | run!("npm install")?; |
101 | 101 | ||
102 | let vsix_pkg = { | 102 | run!("npm run package --scripts-prepend-node-path")?; |
103 | rm("*.vsix")?; | ||
104 | run!("npm run package --scripts-prepend-node-path")?; | ||
105 | ls("*.vsix")?.pop().unwrap() | ||
106 | }; | ||
107 | 103 | ||
108 | let code = find_code(|bin| run!("{} --version", bin).is_ok())?; | 104 | let code = find_code(|bin| run!("{} --version", bin).is_ok())?; |
109 | run!("{} --install-extension {} --force", code, vsix_pkg.display())?; | 105 | run!("{} --install-extension rust-analyzer.vsix --force", code)?; |
110 | installed_extensions = run!("{} --list-extensions", code; echo = false)?; | 106 | installed_extensions = run!("{} --list-extensions", code; echo = false)?; |
111 | } else { | 107 | } else { |
112 | run!("cmd.exe /c npm --version") | 108 | run!("cmd.exe /c npm --version") |
113 | .context("`npm` is required to build the VS Code plugin")?; | 109 | .context("`npm` is required to build the VS Code plugin")?; |
114 | run!("cmd.exe /c npm install")?; | 110 | run!("cmd.exe /c npm install")?; |
115 | 111 | ||
116 | let vsix_pkg = { | 112 | run!("cmd.exe /c npm run package")?; |
117 | rm("*.vsix")?; | ||
118 | run!("cmd.exe /c npm run package")?; | ||
119 | ls("*.vsix")?.pop().unwrap() | ||
120 | }; | ||
121 | 113 | ||
122 | let code = find_code(|bin| run!("cmd.exe /c {}.cmd --version", bin).is_ok())?; | 114 | let code = find_code(|bin| run!("cmd.exe /c {}.cmd --version", bin).is_ok())?; |
123 | run!(r"cmd.exe /c {}.cmd --install-extension {} --force", code, vsix_pkg.display())?; | 115 | run!(r"cmd.exe /c {}.cmd --install-extension rust-analyzer.vsix --force", code)?; |
124 | installed_extensions = run!("cmd.exe /c {}.cmd --list-extensions", code; echo = false)?; | 116 | installed_extensions = run!("cmd.exe /c {}.cmd --list-extensions", code; echo = false)?; |
125 | } | 117 | } |
126 | 118 | ||
diff --git a/xtask/src/not_bash.rs b/xtask/src/not_bash.rs index 3e30e7279..d5577cce9 100644 --- a/xtask/src/not_bash.rs +++ b/xtask/src/not_bash.rs | |||
@@ -2,8 +2,6 @@ | |||
2 | use std::{ | 2 | use std::{ |
3 | cell::RefCell, | 3 | cell::RefCell, |
4 | env, | 4 | env, |
5 | ffi::OsStr, | ||
6 | fs, | ||
7 | path::{Path, PathBuf}, | 5 | path::{Path, PathBuf}, |
8 | process::{Command, Stdio}, | 6 | process::{Command, Stdio}, |
9 | }; | 7 | }; |
@@ -68,14 +66,11 @@ impl Drop for Pushd { | |||
68 | } | 66 | } |
69 | } | 67 | } |
70 | 68 | ||
71 | pub fn rm(glob: &str) -> Result<()> { | ||
72 | let cwd = Env::with(|env| env.cwd()); | ||
73 | ls(glob)?.into_iter().try_for_each(|it| fs::remove_file(cwd.join(it)))?; | ||
74 | Ok(()) | ||
75 | } | ||
76 | |||
77 | pub fn rm_rf(path: impl AsRef<Path>) -> Result<()> { | 69 | pub fn rm_rf(path: impl AsRef<Path>) -> Result<()> { |
78 | let path = path.as_ref(); | 70 | let path = path.as_ref(); |
71 | if !path.exists() { | ||
72 | return Ok(()); | ||
73 | } | ||
79 | if path.is_file() { | 74 | if path.is_file() { |
80 | fs2::remove_file(path) | 75 | fs2::remove_file(path) |
81 | } else { | 76 | } else { |
@@ -83,25 +78,6 @@ pub fn rm_rf(path: impl AsRef<Path>) -> Result<()> { | |||
83 | } | 78 | } |
84 | } | 79 | } |
85 | 80 | ||
86 | pub fn ls(glob: &str) -> Result<Vec<PathBuf>> { | ||
87 | let cwd = Env::with(|env| env.cwd()); | ||
88 | let mut res = Vec::new(); | ||
89 | for entry in fs::read_dir(&cwd)? { | ||
90 | let entry = entry?; | ||
91 | if matches(&entry.file_name(), glob) { | ||
92 | let path = entry.path(); | ||
93 | let path = path.strip_prefix(&cwd).unwrap(); | ||
94 | res.push(path.to_path_buf()) | ||
95 | } | ||
96 | } | ||
97 | return Ok(res); | ||
98 | |||
99 | fn matches(file_name: &OsStr, glob: &str) -> bool { | ||
100 | assert!(glob.starts_with('*')); | ||
101 | file_name.to_string_lossy().ends_with(&glob[1..]) | ||
102 | } | ||
103 | } | ||
104 | |||
105 | #[doc(hidden)] | 81 | #[doc(hidden)] |
106 | pub fn run_process(cmd: String, echo: bool) -> Result<String> { | 82 | pub fn run_process(cmd: String, echo: bool) -> Result<String> { |
107 | run_process_inner(&cmd, echo).with_context(|| format!("process `{}` failed", cmd)) | 83 | run_process_inner(&cmd, echo).with_context(|| format!("process `{}` failed", cmd)) |