aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-04 17:36:16 +0000
committerAleksey Kladov <[email protected]>2020-03-04 17:56:20 +0000
commit694ca4e1856605477961015e4ec3ccd8211bcd34 (patch)
treedd4ce897d17e735e43616d4a816e5f62fe3915df /xtask/src/lib.rs
parenta17c3f791c672c41107e9b4d1ea180bfa989c784 (diff)
Build server via dist as well
Diffstat (limited to 'xtask/src/lib.rs')
-rw-r--r--xtask/src/lib.rs42
1 files changed, 2 insertions, 40 deletions
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs
index 23f85b579..014b61b37 100644
--- a/xtask/src/lib.rs
+++ b/xtask/src/lib.rs
@@ -4,6 +4,7 @@
4 4
5pub mod not_bash; 5pub mod not_bash;
6pub mod install; 6pub mod install;
7pub mod dist;
7pub mod pre_commit; 8pub mod pre_commit;
8 9
9pub mod codegen; 10pub mod codegen;
@@ -19,7 +20,7 @@ use std::{
19 20
20use crate::{ 21use crate::{
21 codegen::Mode, 22 codegen::Mode,
22 not_bash::{fs2, pushd, pwd, rm_rf, run}, 23 not_bash::{fs2, pushd, rm_rf, run},
23}; 24};
24 25
25pub use anyhow::Result; 26pub use anyhow::Result;
@@ -205,42 +206,3 @@ Release: release:{}[]
205fn is_release_tag(tag: &str) -> bool { 206fn is_release_tag(tag: &str) -> bool {
206 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())
207} 208}
208
209pub fn run_dist(nightly: bool) -> Result<()> {
210 let dist = project_root().join("dist");
211 rm_rf(&dist)?;
212 fs2::create_dir_all(&dist)?;
213
214 let _d = pushd("./editors/code");
215
216 let package_json_path = pwd().join("package.json");
217 let original_package_json = fs2::read_to_string(&package_json_path)?;
218 let _restore =
219 Restore { path: package_json_path.clone(), contents: original_package_json.clone() };
220
221 let mut package_json = original_package_json.replace(r#""enableProposedApi": true,"#, r#""#);
222
223 if nightly {
224 package_json = package_json
225 .replace(r#""name": "rust-analyzer""#, r#""name": "rust-analyzer-nightly""#)
226 .replace(
227 r#""displayName": "rust-analyzer""#,
228 r#""displayName": "rust-analyzer nightly""#,
229 );
230 }
231 fs2::write(package_json_path, package_json)?;
232
233 run!("npx vsce package -o {}/rust-analyzer.vsix", dist.display())?;
234 Ok(())
235}
236
237struct Restore {
238 path: PathBuf,
239 contents: String,
240}
241
242impl Drop for Restore {
243 fn drop(&mut self) {
244 fs2::write(&self.path, &self.contents).unwrap();
245 }
246}