pub struct NpmCommand { /* private fields */ }Expand description
A validated package-manager executable plus its fixed argument prefix.
Implementations§
Source§impl NpmCommand
impl NpmCommand
Sourcepub fn resolve(cwd: &Path, project_trusted: bool) -> Result<Self, String>
pub fn resolve(cwd: &Path, project_trusted: bool) -> Result<Self, String>
Resolve the effective command using .rpi, .pi, global, then npm.
Project settings are considered only after the project trust gate has
passed because npmCommand can name an arbitrary executable.
Sourcepub fn from_argv(argv: Option<&[String]>) -> Result<Self, String>
pub fn from_argv(argv: Option<&[String]>) -> Result<Self, String>
Build a command from Pi’s optional argv setting. A missing or empty array selects the platform npm launcher. A blank executable is invalid and never falls back to another command.
Sourcepub fn program(&self) -> &str
pub fn program(&self) -> &str
Executable launched as an argv command. Windows .cmd/.bat shims
use the standard library’s hardened batch argument encoding.
Sourcepub fn prefix_args(&self) -> &[String]
pub fn prefix_args(&self) -> &[String]
Fixed arguments configured before each package-manager operation.
Sourcepub fn is_configured(&self) -> bool
pub fn is_configured(&self) -> bool
Whether the effective command came from an explicit npmCommand.
Sourcepub fn manager_kind(&self) -> NpmManagerKind
pub fn manager_kind(&self) -> NpmManagerKind
Package-manager family used for manager-specific install flags.
Sourcepub fn combined_args(&self, operation_args: &[String]) -> Vec<String>
pub fn combined_args(&self, operation_args: &[String]) -> Vec<String>
Prepend the fixed configured argv to one operation’s arguments.
Sourcepub fn view_args(&self, source_spec: &str) -> Result<Vec<String>, String>
pub fn view_args(&self, source_spec: &str) -> Result<Vec<String>, String>
Construct the complete argv for native Pi’s registry version lookup.
Sourcepub fn install_args(&self, specs: &[String], install_root: &Path) -> Vec<String>
pub fn install_args(&self, specs: &[String], install_root: &Path) -> Vec<String>
Construct manager-specific operation args for a managed npm root.
These match native Pi’s getNpmInstallArgs ordering exactly.
Sourcepub fn uninstall_args(
&self,
package_name: &str,
install_root: &Path,
) -> Vec<String>
pub fn uninstall_args( &self, package_name: &str, install_root: &Path, ) -> Vec<String>
Construct manager-specific arguments for removing one package from a
managed npm root. The ordering and flags match native Pi’s
uninstallNpm implementation.
Sourcepub fn global_package_roots(&self) -> Result<Vec<PathBuf>, String>
pub fn global_package_roots(&self) -> Result<Vec<PathBuf>, String>
Resolve the package-manager’s legacy global install root(s).
Native Pi uses the configured npmCommand for this lookup. The result
is intentionally read-only metadata: callers may use it to discover a
package that predates Pi’s managed store, but must not use it as an
rpi-owned install or removal root. Every returned path is absolute,
canonical, an existing directory, and ends in node_modules.
Sourcepub fn global_package_paths(
&self,
package_names: &[String],
) -> Result<HashMap<String, PathBuf>, String>
pub fn global_package_paths( &self, package_names: &[String], ) -> Result<HashMap<String, PathBuf>, String>
Locate packages in a legacy global install with one package-manager query for the whole batch.
npm/bun use <global root>/<package name>. pnpm reports the concrete
virtual-store path through list -g --depth 0 --json, so that output
is parsed instead of guessing a symlink layout. Returned paths are
canonical read-only discovery paths; package updates must migrate into
the rpi/native managed root before writing anything.
Trait Implementations§
Source§impl Clone for NpmCommand
impl Clone for NpmCommand
Source§fn clone(&self) -> NpmCommand
fn clone(&self) -> NpmCommand
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NpmCommand
impl Debug for NpmCommand
impl Eq for NpmCommand
Source§impl PartialEq for NpmCommand
impl PartialEq for NpmCommand
impl StructuralPartialEq for NpmCommand
Auto Trait Implementations§
impl Freeze for NpmCommand
impl RefUnwindSafe for NpmCommand
impl Send for NpmCommand
impl Sync for NpmCommand
impl Unpin for NpmCommand
impl UnsafeUnpin for NpmCommand
impl UnwindSafe for NpmCommand
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§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
key and return true if they are equal.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
key and return true if they are equal.