Skip to content

Commit

Permalink
option map to if let
Browse files Browse the repository at this point in the history
  • Loading branch information
angeldcampbell authored and mars committed Dec 12, 2024
1 parent 1849991 commit c16d497
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions buildpacks/static-web-server/src/config_web_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ pub(crate) fn config_web_server(
.map_err(StaticWebServerBuildpackError::CannotWriteCaddyConfiguration)?;

// Execute the optional build command
build_command_opt.map(|e| -> Result<Child, StaticWebServerBuildpackError> {
log_info(format!("Executing build command: {e:#?}"));
let mut cmd = Command::new(e.command);
if let Some(args) = e.args {
if let Some(build_command) = build_command_opt {
log_info(format!("Executing build command: {build_command:#?}"));
let mut cmd = Command::new(build_command.command);
if let Some(args) = build_command.args {
cmd.args(args);
}

cmd.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.map_err(StaticWebServerBuildpackError::BuildCommandFailed)
});
cmd.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.output()
.map_err(StaticWebServerBuildpackError::BuildCommandFailed)?;
}

Ok(configuration_layer)
}
Expand Down

0 comments on commit c16d497

Please sign in to comment.