diff --git a/README.md b/README.md index a2fff828f..88edc2b0a 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Experimental package manager for node.js written in rust. - [ ] `outdated` - [ ] `why` - [ ] `licenses` -- [ ] `run` +- [x] `run` - [x] `test` - [ ] `exec` diff --git a/crates/cli/src/commands.rs b/crates/cli/src/commands.rs index 3bdffdf04..9e8c546c6 100644 --- a/crates/cli/src/commands.rs +++ b/crates/cli/src/commands.rs @@ -20,6 +20,9 @@ pub enum Subcommands { Add(AddArgs), /// Runs a package's "test" script, if one was provided. Test, + /// Runs a defined package script. + #[clap(name = "run")] + RunScript(RunScriptArgs), } #[derive(Parser, Debug)] @@ -49,3 +52,9 @@ impl AddArgs { } } } + +#[derive(Parser, Debug)] +pub struct RunScriptArgs { + /// A pre-defined package script. + pub command: String, +} diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index f55c4da01..7c8308b87 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -35,6 +35,10 @@ pub async fn run_commands() -> Result<()> { Subcommands::Test => { PackageJson::from_path(&package_json_path)?.execute_command("test")?; } + Subcommands::RunScript(args) => { + let command = &args.command; + PackageJson::from_path(&package_json_path)?.execute_command(command)?; + } } Ok(())