-
Notifications
You must be signed in to change notification settings - Fork 1
/
elm.rs
47 lines (38 loc) · 1.11 KB
/
elm.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
use displaydoc::Display;
use super::{remove_dirs, status_from_dirs, BuildStatus, BuildTool, BuildToolKind, BuildToolProbe};
use crate::build_tool_manager::BuildToolManager;
use std::path::{Path, PathBuf};
pub fn register(manager: &mut BuildToolManager) {
let probe = Box::new(ElmProbe {});
manager.register(probe);
}
#[derive(Debug)]
pub struct ElmProbe;
impl BuildToolProbe for ElmProbe {
fn probe(&self, dir: &Path) -> Option<Box<dyn BuildTool>> {
if dir.join("elm.json").is_file() {
Some(Box::new(Elm {
dir: dir.to_owned(),
}))
} else {
None
}
}
fn applies_to(&self, kind: BuildToolKind) -> bool {
kind == BuildToolKind::Elm
}
}
#[derive(Debug, Display)]
/// Elm
pub struct Elm {
dir: PathBuf,
}
static EPHEMERAL_DIRS: &[&str] = &["elm-stuff"];
impl BuildTool for Elm {
fn clean_project(&mut self, dry_run: bool) -> anyhow::Result<()> {
remove_dirs(&self.dir, EPHEMERAL_DIRS, dry_run)
}
fn status(&self) -> anyhow::Result<BuildStatus> {
status_from_dirs(&self.dir, EPHEMERAL_DIRS)
}
}