Runner

Enum Runner 

Source
pub enum Runner {
    Npm,
    Yarn,
    Pnpm,
    Bun,
}
Expand description

Supported package managers.

Variants§

§

Npm

Node Package Manager (npm)

§

Yarn

Yarn package manager

§

Pnpm

pnpm - Fast, disk space efficient package manager

§

Bun

Bun - Fast all-in-one JavaScript runtime

Implementations§

Source§

impl Runner

Source

pub fn executable(&self) -> &'static str

Get the executable name for this runner.

Source

pub fn run_prefix(&self) -> &'static str

Get the base run command (without script name).

Returns the command prefix used to run scripts:

  • npm: “npm run”
  • yarn: “yarn”
  • pnpm: “pnpm”
  • bun: “bun run”
Source

pub fn run_command(&self, script: &str) -> Vec<String>

Get the command to run a script as a vector of arguments.

§Examples
use npm_run_scripts::package::Runner;

let cmd = Runner::Npm.run_command("dev");
assert_eq!(cmd, vec!["npm", "run", "dev"]);

let cmd = Runner::Yarn.run_command("build");
assert_eq!(cmd, vec!["yarn", "build"]);
Source

pub fn run_command_with_args( &self, script: &str, args: &[String], ) -> Vec<String>

Get the command to run a script with additional arguments.

§Arguments
  • script - The script name to run
  • args - Additional arguments to pass to the script
§Examples
use npm_run_scripts::package::Runner;

let args = vec!["--watch".to_string(), "--coverage".to_string()];
let cmd = Runner::Npm.run_command_with_args("test", &args);
assert_eq!(cmd, vec!["npm", "run", "test", "--", "--watch", "--coverage"]);
Source

pub fn format_command(&self, script: &str) -> String

Format the run command as a string for display.

§Examples
use npm_run_scripts::package::Runner;

assert_eq!(Runner::Npm.format_command("dev"), "npm run dev");
assert_eq!(Runner::Yarn.format_command("build"), "yarn build");
Source

pub fn format_command_with_args(&self, script: &str, args: &[String]) -> String

Format the run command with arguments as a string for display.

§Examples
use npm_run_scripts::package::Runner;

let args = vec!["--watch".to_string()];
assert_eq!(
    Runner::Npm.format_command_with_args("test", &args),
    "npm run test -- --watch"
);
Source

pub fn display_name(&self) -> &'static str

Get the display name for the runner.

Source

pub fn icon(&self) -> &'static str

Get the icon/emoji for the runner.

Source

pub fn lock_file(&self) -> &'static str

Get the lock file name for this runner.

Source

pub fn all() -> &'static [Runner]

Get all supported runners.

Source

pub fn workspace_command(&self, workspace: &str, script: &str) -> Vec<String>

Get the command to run a workspace script.

§Arguments
  • workspace - The workspace/package name
  • script - The script name to run
Source

pub fn workspace_command_with_args( &self, workspace: &str, script: &str, args: &[String], ) -> Vec<String>

Get the command to run a workspace script with additional arguments.

§Arguments
  • workspace - The workspace/package name
  • script - The script name to run
  • args - Additional arguments to pass to the script
Source

pub fn format_workspace_command(&self, workspace: &str, script: &str) -> String

Format the workspace run command as a string for display.

Source

pub fn format_workspace_command_with_args( &self, workspace: &str, script: &str, args: &[String], ) -> String

Format the workspace run command with arguments as a string for display.

Trait Implementations§

Source§

impl Clone for Runner

Source§

fn clone(&self) -> Runner

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Runner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Runner

Source§

fn default() -> Runner

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Runner

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Runner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<CliRunner> for Runner

Source§

fn from(runner: CliRunner) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Runner

Source§

type Err = String

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Runner

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Runner

Source§

fn eq(&self, other: &Runner) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Runner

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for Runner

Source§

impl Eq for Runner

Source§

impl StructuralPartialEq for Runner

Auto Trait Implementations§

§

impl Freeze for Runner

§

impl RefUnwindSafe for Runner

§

impl Send for Runner

§

impl Sync for Runner

§

impl Unpin for Runner

§

impl UnwindSafe for Runner

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToLine for T
where T: Display,

Source§

fn to_line(&self) -> Line<'_>

Converts the value to a Line.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSpan for T
where T: Display,

Source§

fn to_span(&self) -> Span<'_>

Converts the value to a Span.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToText for T
where T: Display,

Source§

fn to_text(&self) -> Text<'_>

Converts the value to a Text.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,