@@ -7,8 +7,6 @@ use crate::{
77 config:: network:: Network , utils:: explorer_url_for_transaction, utils:: transaction_hash,
88} ;
99
10- const TERMS : & [ & str ] = & [ "Apple_Terminal" , "vscode" ] ;
11-
1210#[ derive( Clone ) ]
1311pub struct Print {
1412 pub quiet : bool ,
@@ -45,14 +43,13 @@ impl Print {
4543
4644 // Some terminals like vscode's and macOS' default terminal will not render
4745 // the subsequent space if the emoji codepoints size is 2; in this case,
48- // we need an additional space.
46+ // we need an additional space. We also need an additional space if `TERM_PROGRAM` is not
47+ // defined (e.g. vhs running in a docker container).
4948 pub fn compute_emoji < T : Display + Sized > ( & self , emoji : T ) -> String {
50- if let Ok ( term_program) = env:: var ( "TERM_PROGRAM" ) {
51- if TERMS . contains ( & term_program. as_str ( ) )
52- && ( emoji. to_string ( ) . chars ( ) . count ( ) == 2 || format ! ( "{emoji}" ) == " " )
53- {
54- return format ! ( "{emoji} " ) ;
55- }
49+ if should_add_additional_space ( )
50+ && ( emoji. to_string ( ) . chars ( ) . count ( ) == 2 || format ! ( "{emoji}" ) == " " )
51+ {
52+ return format ! ( "{emoji} " ) ;
5653 }
5754
5855 emoji. to_string ( )
@@ -102,6 +99,17 @@ macro_rules! create_print_functions {
10299 } ;
103100}
104101
102+ fn should_add_additional_space ( ) -> bool {
103+ const TERMS : & [ & str ] = & [ "Apple_Terminal" , "vscode" , "unknown" ] ;
104+ let term_program = env:: var ( "TERM_PROGRAM" ) . unwrap_or ( "unknown" . to_string ( ) ) ;
105+
106+ if TERMS . contains ( & term_program. as_str ( ) ) {
107+ return true ;
108+ }
109+
110+ false
111+ }
112+
105113create_print_functions ! ( bucket, bucketln, "🪣" ) ;
106114create_print_functions ! ( check, checkln, "✅" ) ;
107115create_print_functions ! ( error, errorln, "❌" ) ;
0 commit comments