Skip to content
This repository was archived by the owner on Jun 14, 2023. It is now read-only.

Commit 6b5a262

Browse files
author
Felix Schütt
committed
Prevent debug output in CI
1 parent 2e8370f commit 6b5a262

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ pub fn set(config: &mut Config, key: String, value: String) -> anyhow::Result<()
438438
if config.registry.get_current_registry() != value {
439439
config.registry.set_current_registry(&value);
440440
}
441+
if !crate::util::allow_debug_output() {
442+
return Ok(());
443+
}
441444
if let Some(u) = crate::util::get_username().ok().and_then(|o| o) {
442445
println!(
443446
"Successfully logged into registry {:?} as user {:?}",
@@ -452,6 +455,9 @@ pub fn set(config: &mut Config, key: String, value: String) -> anyhow::Result<()
452455
&value,
453456
UpdateRegistry::LeaveAsIs,
454457
);
458+
if !crate::util::allow_debug_output() {
459+
return Ok(());
460+
}
455461
if let Some(u) = crate::util::get_username().ok().and_then(|o| o) {
456462
println!(
457463
"Successfully logged into registry {:?} as user {:?}",

src/util.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ pub fn get_username() -> anyhow::Result<Option<String>> {
8181
Ok(response.viewer.map(|viewer| viewer.username))
8282
}
8383

84+
pub fn allow_debug_output() -> bool {
85+
#[cfg(target_os = "wasi")]
86+
{
87+
true
88+
}
89+
#[cfg(not(target_os = "wasi"))]
90+
{
91+
atty::is(atty::Stream::Stdout)
92+
}
93+
}
94+
8495
#[cfg(feature = "telemetry")]
8596
pub fn telemetry_is_enabled() -> bool {
8697
let mut config = if let Ok(c) = crate::config::Config::from_file() {

0 commit comments

Comments
 (0)