Skip to content

Commit 0aef1e7

Browse files
committed
Unify loading message tidying
1 parent ad3e34e commit 0aef1e7

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

lib/Rex/CLI.pm

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -763,13 +763,9 @@ sub load_rexfile {
763763
for (@warnings) {
764764
chomp;
765765

766-
# remove /loader/.../ prefix before filename
767-
s{/loader/[^/]+/}{}sxm;
766+
my $message = _tidy_loading_message( $_, $rexfile );
768767

769-
# convert Rexfile to human-friendly name
770-
s{__Rexfile__.pm}{$rexfile}msx;
771-
772-
Rex::Logger::info( "\t$_", 'warn' );
768+
Rex::Logger::info( "\t$message", 'warn' );
773769
}
774770
}
775771

@@ -780,12 +776,7 @@ sub load_rexfile {
780776
my $e = $@;
781777
chomp $e;
782778

783-
# remove the strange path to the Rexfile which exists because
784-
# we load the Rexfile via our custom code block.
785-
$e =~ s|/loader/[^/]+/||smg;
786-
787-
# convert Rexfile to human-friendly name
788-
$e =~ s{__Rexfile__.pm}{$rexfile}gmsx;
779+
$e = _tidy_loading_message( $e, $rexfile );
789780

790781
my @lines = split( $/, $e );
791782

@@ -796,6 +787,13 @@ sub load_rexfile {
796787
}
797788
}
798789

790+
sub _tidy_loading_message {
791+
my ( $message, $rexfile ) = @_;
792+
793+
$message =~ s{/loader/[^/]+/__Rexfile__[.]pm}{$rexfile}gmsx;
794+
return $message;
795+
}
796+
799797
sub exit_rex {
800798
my ( $exit_code_override, $signal ) = @_;
801799

0 commit comments

Comments
 (0)