Skip to content

Commit e3f7702

Browse files
committed
app: gulpfile
1 parent d4a1c37 commit e3f7702

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/runners/gulpfile.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
use crate::command_utils::{capture_command_output, run_command, CommandOutput};
2+
use crate::errors::KeeperError;
3+
use crate::models::Task;
4+
use crate::task;
5+
use error_stack::Result;
6+
use std::io::BufRead;
7+
use which::which;
8+
9+
pub fn is_available() -> bool {
10+
std::env::current_dir()
11+
.map(|dir| dir.join("gulpfile.js").exists() || dir.join("Gulpfile.js").exists())
12+
.unwrap_or(false)
13+
}
14+
15+
pub fn is_command_available() -> bool {
16+
which("gulp").is_ok()
17+
}
18+
19+
pub fn list_tasks() -> Result<Vec<Task>, KeeperError> {
20+
let jake_tasks_output = capture_command_output("gulp", &["--tasks-simple"])
21+
.map(|output| String::from_utf8(output.stdout).unwrap_or("".to_owned()))?;
22+
let tasks: Vec<Task> = jake_tasks_output
23+
.lines()
24+
.map(|line| {
25+
let task_name = line.trim().to_owned();
26+
task!(task_name, "gulp")
27+
})
28+
.collect();
29+
Ok(tasks)
30+
}
31+
32+
pub fn run_task(
33+
task: &str,
34+
task_args: &[&str],
35+
global_args: &[&str],
36+
verbose: bool,
37+
) -> Result<CommandOutput, KeeperError> {
38+
let mut args = vec![];
39+
args.extend(global_args);
40+
args.push(task);
41+
args.extend(task_args);
42+
run_command("gulp", &args, verbose)
43+
}

0 commit comments

Comments
 (0)