Skip to content

Commit

Permalink
chore: add option to dump args sent to go (#3515)
Browse files Browse the repository at this point in the history
I used this yesterday when debugging package inference and found it
helpful for launching the Go debugger with the correct args. I figure it
might be helpful for other devs as well.
  • Loading branch information
chris-olszewski authored Feb 13, 2023
1 parent a509b2c commit dea257a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/turborepo-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod shim;
mod ui;

use anyhow::Result;
use log::error;
use log::{debug, error, log_enabled, Level};

pub use crate::cli::Args;
use crate::package_manager::PackageManager;
Expand All @@ -32,7 +32,17 @@ pub fn get_version() -> &'static str {

pub fn main() -> Payload {
match shim::run() {
Ok(payload) => payload,
Ok(payload) => {
match &payload {
Payload::Go(args) if log_enabled!(Level::Debug) => {
if let Ok(serialized_args) = serde_json::to_string_pretty(&args) {
debug!("Args passed to Go binary:\n{}", serialized_args);
}
}
_ => (),
}
payload
}
Err(err) => {
error!("{}", err.to_string());
Payload::Rust(Err(err))
Expand Down

0 comments on commit dea257a

Please sign in to comment.