use std::path::Path;
use std::process::Command;
pub(crate) const CLEAN_DIRS: &[&str] = &["vendor"];
pub(crate) fn detect(dir: &Path) -> bool {
dir.join("go.mod").exists()
}
pub(crate) fn install_cmd() -> Command {
let mut c = super::program::command("go");
c.arg("mod").arg("download");
c
}
pub(crate) fn exec_cmd(args: &[String]) -> Command {
let mut c = super::program::command("go");
c.arg("run").args(args);
c
}
#[cfg(test)]
mod tests {
use super::exec_cmd;
#[test]
fn exec_uses_go_run_passthrough() {
let args = [
String::from("example.com/foo@latest"),
String::from("--flag"),
String::from("value"),
];
let built: Vec<_> = exec_cmd(&args)
.get_args()
.map(|arg| arg.to_string_lossy().into_owned())
.collect();
assert_eq!(built, ["run", "example.com/foo@latest", "--flag", "value"]);
}
}