semver-common 0.2.3

Common library to use for semantic release core and plugins.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::{ffi::OsStr, process::Command};

use crate::Alert;

pub fn run_command<I, S>(command: &str, args: I) -> Result<String, Alert>
where
    I: IntoIterator<Item = S>,
    S: AsRef<OsStr>,
{
    let output = Command::new(command).args(args).output()?;
    let stdout = String::from_utf8(output.stdout)?;
    let stderr = String::from_utf8(output.stderr)?;
    let status = output.status.code().ok_or(&stderr)?;
    if status == 0 {
        return Ok(stdout);
    }
    Err(Alert::from(stderr))
}