@@ -5,7 +5,7 @@ use std::time::{Duration, Instant};
5
5
6
6
pub fn print_buildpack_name ( buildpack_name : impl AsRef < str > ) {
7
7
let buildpack_name = buildpack_name. as_ref ( ) ;
8
- println ! ( "{ANSI_BUILDPACK_NAME_CODE}# {buildpack_name}{ANSI_RESET_CODE}\n " ) ;
8
+ print ! ( "\n {ANSI_BUILDPACK_NAME_CODE}# {buildpack_name}{ANSI_RESET_CODE}\n \n " ) ;
9
9
}
10
10
11
11
pub fn print_section ( text : impl Into < BuildpackOutputText > ) {
@@ -71,10 +71,19 @@ pub fn run_command<E, F: FnOnce(std::io::Error) -> E, F2: FnOnce(Output) -> E>(
71
71
let child = if quiet {
72
72
command. output_and_write_streams ( std:: io:: sink ( ) , std:: io:: sink ( ) )
73
73
} else {
74
- command. output_and_write_streams (
75
- line_mapped ( std:: io:: stdout ( ) , add_prefix_to_non_empty ( " " ) ) ,
76
- line_mapped ( std:: io:: stderr ( ) , add_prefix_to_non_empty ( " " ) ) ,
77
- )
74
+ const SPACE_ASCII : u8 = 0x20 ;
75
+ let prefix = vec ! [ SPACE_ASCII ; 6 ] ;
76
+
77
+ println ! ( ) ;
78
+
79
+ let output = command. output_and_write_streams (
80
+ line_mapped ( std:: io:: stdout ( ) , add_prefix_to_non_empty ( prefix. clone ( ) ) ) ,
81
+ line_mapped ( std:: io:: stderr ( ) , add_prefix_to_non_empty ( prefix) ) ,
82
+ ) ;
83
+
84
+ println ! ( ) ;
85
+
86
+ output
78
87
} ;
79
88
80
89
child. map_err ( io_error_fn) . and_then ( |output| {
@@ -222,6 +231,10 @@ impl BuildpackOutputTextSection {
222
231
pub fn value ( value : impl Into < String > ) -> Self {
223
232
BuildpackOutputTextSection :: Value ( value. into ( ) )
224
233
}
234
+
235
+ pub fn command ( value : impl Into < String > ) -> Self {
236
+ BuildpackOutputTextSection :: Command ( value. into ( ) )
237
+ }
225
238
}
226
239
227
240
impl From < String > for BuildpackOutputText {
@@ -283,12 +296,12 @@ fn format_duration(duration: &Duration) -> String {
283
296
284
297
const VALUE_DELIMITER_CHAR : char = '`' ;
285
298
const ANSI_RESET_CODE : & str = "\u{1b} [0m" ;
286
- const ANSI_VALUE_CODE : & str = "\u{1b} [0;34m " ;
299
+ const ANSI_VALUE_CODE : & str = "\u{1b} [0;33m " ;
287
300
const ANSI_YELLOW_CODE : & str = "\u{1b} [0;33m" ;
288
301
const ANSI_RED_CODE : & str = "\u{1b} [0;31m" ;
289
302
const ANSI_BUILDPACK_NAME_CODE : & str = "\u{1b} [1;35m" ;
290
303
const ANSI_URL_CODE : & str = "\u{1b} [0;34m" ;
291
- const ANSI_COMMAND_CODE : & str = "\u{1b} [0;34m " ;
304
+ const ANSI_COMMAND_CODE : & str = "\u{1b} [1;36m " ;
292
305
const ERROR_WARNING_LINE_PREFIX : & str = "! " ;
293
306
294
307
#[ cfg( test) ]
@@ -311,7 +324,7 @@ mod test {
311
324
..Default :: default ( )
312
325
} ;
313
326
314
- assert_eq ! ( text. to_ansi_string( ) , "\u{1b} [0m\u{1b} [0;33m! Hello\u{1b} [0m\n \u{1b} [0m\u{1b} [0;33m! `\u{1b} [0;34mWorld \u{1b} [0m`\u{1b} [0;33m\u{1b} [0m\n \u{1b} [0m\u{1b} [0;33m! How\u{1b} [0m\n \u{1b} [0m\u{1b} [0;33m! are you?" ) ;
327
+ assert_eq ! ( text. to_ansi_string( ) , "\u{1b} [0m\u{1b} [0;33m! Hello\u{1b} [0m\n \u{1b} [0m\u{1b} [0;33m! `\u{1b} [0;33mWorld \u{1b} [0m`\u{1b} [0;33m\u{1b} [0m\n \u{1b} [0m\u{1b} [0;33m! How\u{1b} [0m\n \u{1b} [0m\u{1b} [0;33m! are you?" ) ;
315
328
}
316
329
317
330
#[ test]
@@ -329,7 +342,7 @@ mod test {
329
342
330
343
assert_eq ! (
331
344
text. to_ansi_string( ) ,
332
- "\u{1b} [0m\u{1b} [0;33m! Intro\u{1b} [0m\n \u{1b} [0m\u{1b} [0;33m! `\u{1b} [0;34mWith \u{1b} [0m\n \u{1b} [0m\u{1b} [0;33m! \u{1b} [0;34mNewline \u{1b} [0m`\u{1b} [0;33m\u{1b} [0m\n \u{1b} [0m\u{1b} [0;33m! Outro"
345
+ "\u{1b} [0m\u{1b} [0;33m! Intro\u{1b} [0m\n \u{1b} [0m\u{1b} [0;33m! `\u{1b} [0;33mWith \u{1b} [0m\n \u{1b} [0m\u{1b} [0;33m! \u{1b} [0;33mNewline \u{1b} [0m`\u{1b} [0;33m\u{1b} [0m\n \u{1b} [0m\u{1b} [0;33m! Outro"
333
346
) ;
334
347
}
335
348
0 commit comments