Struct npm_rs::Npm[][src]

pub struct Npm { /* fields omitted */ }
Expand description

This struct is used to execute npm commands. Can be created from NpmEnv of using Default.

After queuing the desired commands, use Npm::exec() to execute them.

Example

use npm_rs::*;

Npm::default().install(Some(&["tailwindcss"])).exec()?;

Implementations

Same behaviour as npm-init -y. Initializes a package, creating a package.json file with the default template.

Same behaviour as npm-install.

  • If args =None: Installs all the dependencies listed in package.json into the local node_modules folder.
  • If args =Some: Installs any package in args into the local node_modules folder.

Same behaviour as npm-uninstall. Uninstalls the given packages in pkg.

Same behaviour as npm-update.

  • If args =None: Updates all the local dependencies (local node_modules folder).
  • If args =Some: Updates any package in pkg.

Same behaviour as npm-run-script. Runs an arbitrary command from package.json’s “scripts” object.

Runs a custom npm command.

Arguments

  • command: command to execute.
  • args: arguments of command.

Example

use npm_rs::*;

Npm::default().custom("audit", None).exec()?; // Equivalent to `npm audit`.

Executes all the commands in the invokation order used, waiting for its completion status.

Example

use npm_rs::*;

let status = Npm::default().install(None).run("build").exec()?; // Executes npm install && npm run build.
assert!(status.success()); // Will `panic` if not completed successfully.

Trait Implementations

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.