forked from github-starred/komodo
* add close alert threshold to prevent Ok - Warning back and forth * remove part about repo being deleted, no longer behavior * resource sync share general common * remove this changelog. use releases * remove changelog from readme * write commit file clean up path * docs: supports any git provider repo * fix docs: authorization * multiline command supports escaped newlines * move webhook to build config advanced * parser comments with escaped newline * improve parser * save use Enter. escape monaco using escape * improve logic when deployment / stack action buttons shown * used_mem = total - available * Fix unrecognized path have 404 * webhooks will 404 if misconfigured * move update logger / alerter * delete migrator * update examples * publish typescript client komodo_client
46 lines
1.1 KiB
Rust
46 lines
1.1 KiB
Rust
use std::path::Path;
|
|
|
|
use komodo_client::{
|
|
entities::{komodo_timestamp, update::Log},
|
|
parser::parse_multiline_command,
|
|
};
|
|
use run_command::{async_run_command, CommandOutput};
|
|
|
|
/// Parses commands out of multiline string
|
|
/// and chains them together with '&&'
|
|
///
|
|
/// Supports full line and end of line comments. See [parse_multiline_command].
|
|
pub async fn run_komodo_command(
|
|
stage: &str,
|
|
path: impl Into<Option<&Path>>,
|
|
command: impl AsRef<str>,
|
|
) -> Log {
|
|
let command = parse_multiline_command(command);
|
|
let command = if let Some(path) = path.into() {
|
|
format!("cd {} && {command}", path.display(),)
|
|
} else {
|
|
command
|
|
};
|
|
let start_ts = komodo_timestamp();
|
|
let output = async_run_command(&command).await;
|
|
output_into_log(stage, command, start_ts, output)
|
|
}
|
|
|
|
pub fn output_into_log(
|
|
stage: &str,
|
|
command: String,
|
|
start_ts: i64,
|
|
output: CommandOutput,
|
|
) -> Log {
|
|
let success = output.success();
|
|
Log {
|
|
stage: stage.to_string(),
|
|
stdout: output.stdout,
|
|
stderr: output.stderr,
|
|
command,
|
|
success,
|
|
start_ts,
|
|
end_ts: komodo_timestamp(),
|
|
}
|
|
}
|