Skip to content

Commit

Permalink
feat: add run command
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Jul 18, 2023
1 parent a6b7806 commit 9c2da0f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Experimental package manager for node.js written in rust.
- [ ] `outdated`
- [ ] `why`
- [ ] `licenses`
- [ ] `run`
- [x] `run`
- [x] `test`
- [ ] `exec`

Expand Down
9 changes: 9 additions & 0 deletions crates/cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -49,3 +52,9 @@ impl AddArgs {
}
}
}

#[derive(Parser, Debug)]
pub struct RunScriptArgs {
/// A pre-defined package script.
pub command: String,
}
4 changes: 4 additions & 0 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down

0 comments on commit 9c2da0f

Please sign in to comment.