Browse Source

Enable multi-line build for more explicit packaging

tags/v0.3.7rc0
haixuanTao 1 year ago
parent
commit
c30d9cda91
2 changed files with 23 additions and 15 deletions
  1. +17
    -15
      binaries/cli/src/build.rs
  2. +6
    -0
      tests/multiline_build/dataflow.yml

+ 17
- 15
binaries/cli/src/build.rs View File

@@ -59,22 +59,24 @@ pub fn build(dataflow: &Path) -> eyre::Result<()> {

fn run_build_command(build: Option<&str>, working_dir: &Path) -> eyre::Result<()> {
if let Some(build) = build {
let mut split = build.split_whitespace();
let mut cmd = Command::new(
split
.next()
.ok_or_else(|| eyre!("build command is empty"))?,
);
cmd.args(split);
cmd.current_dir(working_dir);
let exit_status = cmd
.status()
.wrap_err_with(|| format!("failed to run `{}`", build))?;
if exit_status.success() {
Ok(())
} else {
Err(eyre!("build command returned an error code"))
let lines = build.lines().collect::<Vec<_>>();
for build_line in lines {
let mut split = build_line.split_whitespace();
let mut cmd = Command::new(
split
.next()
.ok_or_else(|| eyre!("build command is empty"))?,
);
cmd.args(split);
cmd.current_dir(working_dir);
let exit_status = cmd
.status()
.wrap_err_with(|| format!("failed to run `{}`", build))?;
if !exit_status.success() {
return Err(eyre!("build command `{build_line}` returned {exit_status}"));
}
}
Ok(())
} else {
Ok(())
}


+ 6
- 0
tests/multiline_build/dataflow.yml View File

@@ -0,0 +1,6 @@
nodes:
- id: dora-microphone
build: |
pip install -e ../../node-hub/dora-microphone
pip install -e ../../node-hub/dora-vad
path: dora-microphone

Loading…
Cancel
Save