Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/commands/emulator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::args::EmulatorArgs;
use crate::langs::check_output;
use crate::langs::check_exit_status;
use anyhow::{Context, Result, bail};
use flate2::read::GzDecoder;
use std::fs::File;
Expand All @@ -20,8 +20,8 @@ pub fn cmd_emulator(vfs: &Path, args: &EmulatorArgs) -> Result<()> {
download_emulator(&bin_path).context("download emulator")?;
}
println!("⌛ running...");
let output = Command::new(bin_path).args(&args.args).output()?;
check_output(&output).context("run emulator")?;
let exit_status = Command::new(bin_path).args(&args.args).status()?;
check_exit_status(exit_status).context("run emulator")?;
Ok(())
}

Expand Down
10 changes: 7 additions & 3 deletions src/langs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::env::temp_dir;
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::{Command, Output};
use std::process::{Command, ExitStatus, Output};

pub fn build_bin(config: &Config, args: &BuildArgs) -> anyhow::Result<()> {
// Don't build the binary if it will be copied directly in "files".
Expand Down Expand Up @@ -511,8 +511,12 @@ pub fn path_to_utf8(path: &Path) -> anyhow::Result<&str> {
pub fn check_output(output: &Output) -> anyhow::Result<()> {
std::io::stdout().write_all(&output.stdout)?;
std::io::stderr().write_all(&output.stderr)?;
if !output.status.success() {
let code = output.status.code().unwrap_or(1);
check_exit_status(output.status)
}

pub fn check_exit_status(output: ExitStatus) -> anyhow::Result<()> {
if !output.success() {
let code = output.code().unwrap_or(1);
bail!("subprocess exited with status code {code}");
}
Ok(())
Expand Down