mk_lib/schema/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
mod command;
mod include;
mod precondition;
mod task;
mod task_context;
mod task_dependency;
mod task_root;
mod use_cargo;
mod use_npm;

use std::collections::HashSet;
use std::process::Stdio;
use std::sync::{
  Arc,
  Mutex,
};

pub type ExecutionStack = Arc<Mutex<HashSet<String>>>;

pub use command::*;
pub use include::*;
pub use precondition::*;
pub use task::*;
pub use task_context::*;
pub use task_dependency::*;
pub use task_root::*;
pub use use_cargo::*;
pub use use_npm::*;

pub fn is_shell_command(value: &str) -> anyhow::Result<bool> {
  use regex::Regex;

  let re = Regex::new(r"^\$\(.+\)$")?;
  Ok(re.is_match(value))
}

pub fn is_template_command(value: &str) -> anyhow::Result<bool> {
  use regex::Regex;

  let re = Regex::new(r"^\$\{\{.+\}\}$")?;
  Ok(re.is_match(value))
}

pub fn get_output_handler(verbose: bool) -> Stdio {
  if verbose {
    Stdio::piped()
  } else {
    Stdio::null()
  }
}