Skip to content

Commit

Permalink
fix(exec): never print information
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanccn committed Apr 4, 2024
1 parent d622834 commit ff7320e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 34 deletions.
11 changes: 3 additions & 8 deletions src/cli/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ pub fn handle(package_paths: impl Iterator<Item = PathBuf>, args: &ExecArgs) ->
if let Ok(Ok(package)) =
fs::read(&package_path).map(|mut raw| simd_json::from_slice::<PackageJson>(&mut raw))
{
if !args.silent {
eprint!("{}", package.make_prefix(None, Stream::Stderr));

run_exec(&package_path, &package, args)?;

executed_exec = true;
break;
}
run_exec(&package_path, &package, args)?;
executed_exec = true;
break;
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ pub struct ExecArgs {
#[clap(required = true, allow_hyphen_values = true)]
pub command: Vec<String>,

/// Disable printing package and command information
#[clap(short, long, env = "NRR_SILENT")]
pub silent: bool,

/// An environment file to read environment variables from
#[clap(short, long, env = "NRR_ENV_FILE", value_parser = EnvFile::from_path)]
pub env_file: Option<EnvFile>,
Expand Down
23 changes: 1 addition & 22 deletions src/run/exec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::{env, path::Path, process::Command};

use color_eyre::Result;
use owo_colors::{OwoColorize as _, Stream};
use std::{env, path::Path, process::Command};

#[cfg(unix)]
use std::os::unix::process::CommandExt as _;
Expand All @@ -11,25 +9,6 @@ use crate::{cli::ExecArgs, package_json::PackageJson, run::util};
pub fn run_exec(package_path: &Path, package_data: &PackageJson, args: &ExecArgs) -> Result<()> {
let package_folder = package_path.parent().unwrap();

let escaped_command = args
.command
.iter()
.map(|f| shlex::try_quote(f))
.collect::<Result<Vec<_>, _>>()?
.join(" ");

if !args.silent {
let cmd_prefix = "$".repeat(*crate::get_level());

eprintln!(
"{} {}",
cmd_prefix
.if_supports_color(Stream::Stderr, |text| text.cyan())
.if_supports_color(Stream::Stderr, |text| text.dimmed()),
escaped_command.if_supports_color(Stream::Stderr, |text| text.dimmed()),
);
}

let mut command_iter = args.command.iter();
let mut subproc = Command::new(command_iter.next().unwrap());
subproc.current_dir(package_folder).args(command_iter);
Expand Down

0 comments on commit ff7320e

Please sign in to comment.