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
impl Runner
Sourcepub fn executable(&self) -> &'static str
pub fn executable(&self) -> &'static str
Get the executable name for this runner.
Sourcepub fn run_prefix(&self) -> &'static str
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”
Sourcepub fn run_command(&self, script: &str) -> Vec<String>
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"]);Sourcepub fn run_command_with_args(
&self,
script: &str,
args: &[String],
) -> Vec<String>
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 runargs- 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"]);Sourcepub fn format_command(&self, script: &str) -> String
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");Sourcepub fn format_command_with_args(&self, script: &str, args: &[String]) -> String
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"
);Sourcepub fn display_name(&self) -> &'static str
pub fn display_name(&self) -> &'static str
Get the display name for the runner.
Sourcepub fn workspace_command(&self, workspace: &str, script: &str) -> Vec<String>
pub fn workspace_command(&self, workspace: &str, script: &str) -> Vec<String>
Get the command to run a workspace script.
§Arguments
workspace- The workspace/package namescript- The script name to run
Sourcepub fn workspace_command_with_args(
&self,
workspace: &str,
script: &str,
args: &[String],
) -> Vec<String>
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 namescript- The script name to runargs- Additional arguments to pass to the script
Sourcepub fn format_workspace_command(&self, workspace: &str, script: &str) -> String
pub fn format_workspace_command(&self, workspace: &str, script: &str) -> String
Format the workspace run command as a string for display.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Runner
impl<'de> Deserialize<'de> for Runner
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Runner
impl Eq for Runner
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
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
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more