Skip to main content

cli/lib/runners/
abstract_runner.rs

1//! Upstream source: `../nest-cli/lib/runners/abstract.runner.ts`.
2
3use std::path::PathBuf;
4
5use super::{ProcessRunner, Runner, RunnerKind};
6
7pub type RunnerCommand = super::RunnerCommand;
8pub type RunnerExecution = super::RunnerExecution;
9
10#[derive(Clone, Debug, Eq, PartialEq)]
11pub struct AbstractRunner {
12    inner: ProcessRunner,
13}
14
15impl AbstractRunner {
16    pub fn new(kind: RunnerKind) -> Self {
17        Self {
18            inner: ProcessRunner::new(kind),
19        }
20    }
21
22    pub fn with_binary(kind: RunnerKind, binary: impl Into<String>) -> Self {
23        Self {
24            inner: ProcessRunner::with_binary(kind, binary),
25        }
26    }
27
28    pub fn inner(&self) -> &ProcessRunner {
29        &self.inner
30    }
31
32    pub fn into_inner(self) -> ProcessRunner {
33        self.inner
34    }
35}
36
37impl Runner for AbstractRunner {
38    fn kind(&self) -> RunnerKind {
39        self.inner.kind()
40    }
41
42    fn binary(&self) -> &str {
43        self.inner.binary()
44    }
45
46    fn prefix_args(&self) -> &[String] {
47        self.inner.prefix_args()
48    }
49}
50
51pub fn describe(
52    runner: &impl Runner,
53    command: impl Into<String>,
54    collect: bool,
55    cwd: Option<PathBuf>,
56) -> RunnerCommand {
57    runner.describe(command, collect, cwd)
58}