From fd586e58d97e4ac2d2448426cf6c4937b48c5660 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 4 Mar 2020 17:58:22 +0100 Subject: cargo xtask dist This builds the typescript extension --- xtask/src/not_bash.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'xtask/src/not_bash.rs') diff --git a/xtask/src/not_bash.rs b/xtask/src/not_bash.rs index 40f706d9f..1697b7fcd 100644 --- a/xtask/src/not_bash.rs +++ b/xtask/src/not_bash.rs @@ -19,6 +19,11 @@ pub mod fs2 { fs::read_dir(path).with_context(|| format!("Failed to read {}", path.display())) } + pub fn read_to_string>(path: P) -> Result { + let path = path.as_ref(); + fs::read_to_string(path).with_context(|| format!("Failed to read {}", path.display())) + } + pub fn write, C: AsRef<[u8]>>(path: P, contents: C) -> Result<()> { let path = path.as_ref(); fs::write(path, contents).with_context(|| format!("Failed to write {}", path.display())) @@ -40,6 +45,11 @@ pub mod fs2 { let path = path.as_ref(); fs::remove_dir_all(path).with_context(|| format!("Failed to remove dir {}", path.display())) } + + pub fn create_dir_all>(path: P) -> Result<()> { + let path = path.as_ref(); + fs::create_dir_all(path).with_context(|| format!("Failed to create dir {}", path.display())) + } } macro_rules! _run { @@ -61,6 +71,10 @@ pub fn pushd(path: impl Into) -> Pushd { Pushd { _p: () } } +pub fn pwd() -> PathBuf { + Env::with(|env| env.cwd()) +} + impl Drop for Pushd { fn drop(&mut self) { Env::with(|env| env.popd()) @@ -85,7 +99,6 @@ pub fn run_process(cmd: String, echo: bool) -> Result { } fn run_process_inner(cmd: &str, echo: bool) -> Result { - let cwd = Env::with(|env| env.cwd()); let mut args = shelx(cmd); let binary = args.remove(0); @@ -95,7 +108,7 @@ fn run_process_inner(cmd: &str, echo: bool) -> Result { let output = Command::new(binary) .args(args) - .current_dir(cwd) + .current_dir(pwd()) .stdin(Stdio::null()) .stderr(Stdio::inherit()) .output()?; -- cgit v1.2.3