Added self-update command

This commit is contained in:
Syrus Akbary
2018-11-25 21:31:32 -08:00
parent 399d253bc1
commit f186ed8534
3 changed files with 97 additions and 19 deletions

17
src/update.rs Normal file
View File

@ -0,0 +1,17 @@
//! When wasmer self-update is executed, this is what gets executed
use std::process::{Command, Stdio};
use std::io;
pub fn self_update() {
println!("Fetching latest installer");
let cmd = Command::new("curl").arg("https://get.wasmer.io").arg("-sSfL")
.stdout(Stdio::piped()).spawn().unwrap();
let mut the_process = Command::new("sh")
.stdin(cmd.stdout.unwrap())
.stdout(Stdio::inherit())
.spawn()
.ok().expect("Failed to execute.");
the_process.wait();
}