-
Notifications
You must be signed in to change notification settings - Fork 180
Expand file tree
/
Copy pathdoc.rs
More file actions
31 lines (29 loc) · 1.05 KB
/
doc.rs
File metadata and controls
31 lines (29 loc) · 1.05 KB
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
use std::{future::Future, iter::once};
use petgraph::stable_graph::StableGraph;
use vite_error::Error as ViteError;
use vite_task::{
Error, ExecutionPlan, ExecutionSummary, ResolveCommandResult, ResolvedTask, Workspace,
};
pub async fn doc<
Doc: Future<Output = Result<ResolveCommandResult, ViteError>>,
DocFn: Fn() -> Doc,
>(
resolve_doc_command: DocFn,
workspace: &Workspace,
args: &Vec<String>,
) -> Result<ExecutionSummary, Error> {
let ResolveCommandResult { bin_path, envs } =
resolve_doc_command().await.map_err(|e| Error::Anyhow(e.into()))?;
let wrapped_command =
|| async { Ok(ResolveCommandResult { bin_path: "node".into(), envs: envs.clone() }) };
let resolved_task = ResolvedTask::resolve_from_builtin(
workspace,
wrapped_command,
"doc",
once(&bin_path).chain(args.iter()),
)
.await?;
let mut task_graph: StableGraph<ResolvedTask, ()> = Default::default();
task_graph.add_node(resolved_task);
ExecutionPlan::plan(task_graph, false)?.execute(workspace).await
}