diff options
Diffstat (limited to 'xtask/src/lib.rs')
-rw-r--r-- | xtask/src/lib.rs | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index f48045d17..adbee10ee 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs | |||
@@ -19,7 +19,7 @@ use std::{ | |||
19 | 19 | ||
20 | use crate::{ | 20 | use crate::{ |
21 | codegen::Mode, | 21 | codegen::Mode, |
22 | not_bash::{fs2, pushd, rm_rf, run}, | 22 | not_bash::{fs2, pushd, pwd, rm_rf, run}, |
23 | }; | 23 | }; |
24 | 24 | ||
25 | pub use anyhow::Result; | 25 | pub use anyhow::Result; |
@@ -206,3 +206,42 @@ Release: release:{}[] | |||
206 | fn is_release_tag(tag: &str) -> bool { | 206 | fn is_release_tag(tag: &str) -> bool { |
207 | tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit()) | 207 | tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit()) |
208 | } | 208 | } |
209 | |||
210 | pub fn run_dist(nightly: bool) -> Result<()> { | ||
211 | let dist = project_root().join("dist"); | ||
212 | rm_rf(&dist)?; | ||
213 | fs2::create_dir_all(&dist)?; | ||
214 | |||
215 | let _d = pushd("./editors/code"); | ||
216 | |||
217 | let package_json_path = pwd().join("package.json"); | ||
218 | let original_package_json = fs2::read_to_string(&package_json_path)?; | ||
219 | let _restore = | ||
220 | Restore { path: package_json_path.clone(), contents: original_package_json.clone() }; | ||
221 | |||
222 | let mut package_json = original_package_json.replace(r#""enableProposedApi": true,"#, r#""#); | ||
223 | |||
224 | if nightly { | ||
225 | package_json = package_json | ||
226 | .replace(r#""name": "rust-analyzer""#, r#""name": "rust-analyzer-nightly""#) | ||
227 | .replace( | ||
228 | r#""displayName": "rust-analyzer""#, | ||
229 | r#""displayName": "rust-analyzer nightly""#, | ||
230 | ); | ||
231 | } | ||
232 | fs2::write(package_json_path, package_json)?; | ||
233 | |||
234 | run!("npx vsce package -o {}/rust-analyzer.vsix", dist.display())?; | ||
235 | Ok(()) | ||
236 | } | ||
237 | |||
238 | struct Restore { | ||
239 | path: PathBuf, | ||
240 | contents: String, | ||
241 | } | ||
242 | |||
243 | impl Drop for Restore { | ||
244 | fn drop(&mut self) { | ||
245 | fs2::write(&self.path, &self.contents).unwrap(); | ||
246 | } | ||
247 | } | ||