Skip to content

Commit

Permalink
Correct output
Browse files Browse the repository at this point in the history
  • Loading branch information
tknickman committed Oct 15, 2024
1 parent d25dc01 commit 436bc5e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
16 changes: 8 additions & 8 deletions crates/turborepo-env/src/platform.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use turborepo_ci::Vendor;
use turborepo_ui::{color, cprint, cprintln, ColorConfig, BOLD, GREY, UNDERLINE, YELLOW};
use turborepo_ui::{ceprint, ceprintln, color, ColorConfig, BOLD, GREY, UNDERLINE, YELLOW};

use crate::EnvironmentVariableMap;

Expand Down Expand Up @@ -63,7 +63,7 @@ impl PlatformEnv {

match ci {
"VERCEL" => {
cprintln!(
ceprintln!(
color_config,
BOLD,
"The following environment variables are set on your Vercel project, but \
Expand All @@ -72,7 +72,7 @@ impl PlatformEnv {
);
}
_ => {
cprintln!(
ceprintln!(
color_config,
BOLD,
"The following environment variables are missing from \"turbo.json\". {}",
Expand All @@ -86,19 +86,19 @@ impl PlatformEnv {
UNDERLINE,
"https://turbo.build/repo/docs/platform-environment-variables"
);
cprintln!(color_config, GREY, "Learn more at {docs}\n");
ceprintln!(color_config, GREY, "Learn more at {docs}\n");
}

pub fn output_for_task(
missing: Vec<String>,
task_id_for_display: &str,
color_config: ColorConfig,
) {
cprintln!(color_config, YELLOW, "{}", task_id_for_display);
ceprintln!(color_config, YELLOW, "{}", task_id_for_display);
for key in missing {
cprint!(color_config, GREY, " - ");
cprint!(color_config, GREY, "{}\n", key);
ceprint!(color_config, GREY, " - ");
ceprint!(color_config, GREY, "{}\n", key);
}
println!();
eprintln!();
}
}
4 changes: 2 additions & 2 deletions crates/turborepo-lib/src/task_graph/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,9 @@ impl<'a> Visitor<'a> {
// output any warnings that we collected while running tasks
if let Ok(warnings) = self.warnings.lock() {
if !warnings.is_empty() {
println!();
eprintln!();
warn!("finished with warnings");
println!();
eprintln!();

let has_missing_platform_env: bool = warnings
.iter()
Expand Down
22 changes: 22 additions & 0 deletions crates/turborepo-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,28 @@ macro_rules! cwriteln {
}};
}

#[macro_export]
macro_rules! ceprintln {
($ui:expr, $color:expr, $format_string:expr $(, $arg:expr)*) => {{
let formatted_str = format!($format_string $(, $arg)*);

let colored_str = $color.apply_to(formatted_str);

eprintln!("{}", $ui.apply(colored_str))
}};
}

#[macro_export]
macro_rules! ceprint {
($ui:expr, $color:expr, $format_string:expr $(, $arg:expr)*) => {{
let formatted_str = format!($format_string $(, $arg)*);

let colored_str = $color.apply_to(formatted_str);

eprint!("{}", $ui.apply(colored_str))
}};
}

/// Helper struct to apply any necessary formatting to UI output
#[derive(Debug, Clone, Copy)]
pub struct ColorConfig {
Expand Down

0 comments on commit 436bc5e

Please sign in to comment.