aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-04 16:58:22 +0000
committerAleksey Kladov <[email protected]>2020-03-04 17:18:20 +0000
commitfd586e58d97e4ac2d2448426cf6c4937b48c5660 (patch)
tree7c7bba3328a85b0f4c5d9a3b7d9f3c3e3616b4f4 /xtask/src/lib.rs
parentae6109a68ce6980bdaeb3824adfc14417d40aa4a (diff)
cargo xtask dist
This builds the typescript extension
Diffstat (limited to 'xtask/src/lib.rs')
-rw-r--r--xtask/src/lib.rs41
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
20use crate::{ 20use 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
25pub use anyhow::Result; 25pub use anyhow::Result;
@@ -206,3 +206,42 @@ Release: release:{}[]
206fn is_release_tag(tag: &str) -> bool { 206fn 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
210pub 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
238struct Restore {
239 path: PathBuf,
240 contents: String,
241}
242
243impl Drop for Restore {
244 fn drop(&mut self) {
245 fs2::write(&self.path, &self.contents).unwrap();
246 }
247}