|
|
|
@ -28,6 +28,15 @@ impl From<&str> for Command {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Command {
|
|
|
|
|
pub fn is_empty(&self) -> bool {
|
|
|
|
|
match self {
|
|
|
|
|
Command::Multiple(v) => v.is_empty(),
|
|
|
|
|
Command::Single(v) => v.is_empty(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl std::fmt::Display for Command {
|
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
|
match self {
|
|
|
|
@ -98,7 +107,7 @@ impl Project {
|
|
|
|
|
.flat_map(|jobs| jobs.to_vec())
|
|
|
|
|
.collect::<Vec<_>>();
|
|
|
|
|
jobs.push(job);
|
|
|
|
|
Jobs::new(jobs)
|
|
|
|
|
Jobs::new(jobs.into_iter().filter(|t| !t.command.is_empty()).collect())
|
|
|
|
|
})
|
|
|
|
|
.or_else(|| {
|
|
|
|
|
self.components.iter().find_map(|(c_name, component)| {
|
|
|
|
@ -137,7 +146,7 @@ impl Project {
|
|
|
|
|
.flat_map(|jobs| jobs.to_vec())
|
|
|
|
|
.collect::<Vec<_>>();
|
|
|
|
|
jobs.push(job);
|
|
|
|
|
Jobs::new(jobs)
|
|
|
|
|
Jobs::new(jobs.into_iter().filter(|t| !t.command.is_empty()).collect())
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
@ -311,7 +320,7 @@ impl Default for Component {
|
|
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub struct TaskDefinition {
|
|
|
|
|
pub description: String,
|
|
|
|
|
pub description: Option<String>,
|
|
|
|
|
/// A map of environment variables that are provided before running the task
|
|
|
|
|
pub env: HashMap<String, String>,
|
|
|
|
|
/// The command(s) to execute when the task is launched
|
|
|
|
@ -329,6 +338,7 @@ impl From<&TaskDefinition> for Job {
|
|
|
|
|
command: source.command.clone(),
|
|
|
|
|
retry: false,
|
|
|
|
|
keep_alive: false,
|
|
|
|
|
path: source.path.clone().unwrap_or_else(|| String::from(".")),
|
|
|
|
|
retry_delay: 0,
|
|
|
|
|
..Default::default()
|
|
|
|
|
}
|
|
|
|
@ -458,8 +468,7 @@ mod tests {
|
|
|
|
|
assert_eq!(jobs.get(0).unwrap().name, "ui:build-ui");
|
|
|
|
|
assert_eq!(jobs.get(1).unwrap().name, "server:setup");
|
|
|
|
|
assert_eq!(jobs.get(2).unwrap().name, "server:build");
|
|
|
|
|
assert_eq!(jobs.get(3).unwrap().name, "build");
|
|
|
|
|
assert_eq!(jobs.len(), 4);
|
|
|
|
|
assert_eq!(jobs.len(), 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|