Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: highlight output
Browse files Browse the repository at this point in the history
ferki committed Aug 10, 2024
1 parent d74be89 commit 0a61d1f
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.024.
# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.032.
use strict;
use warnings;

@@ -18,6 +18,7 @@ my %WriteMakefileArgs = (
"NAME" => "Rex::Hook::File::Diff",
"PREREQ_PM" => {
"File::Basename" => 0,
"IPC::Run" => 0,
"Rex" => "1.013004",
"Rex::Helper::Run" => 0,
"Rex::Hook" => 0,
@@ -46,6 +47,7 @@ my %FallbackPrereqs = (
"File::Basename" => 0,
"File::Temp" => 0,
"File::Touch" => "0.08",
"IPC::Run" => 0,
"Rex" => "1.013004",
"Rex::Commands::File" => "1.012",
"Rex::Helper::Run" => 0,
3 changes: 2 additions & 1 deletion cpanfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# This file is generated by Dist::Zilla::Plugin::CPANFile v6.024
# This file is generated by Dist::Zilla::Plugin::CPANFile v6.032
# Do not edit this file directly. To change prereqs, edit the `dist.ini` file.

requires "File::Basename" => "0";
requires "IPC::Run" => "0";
requires "Rex" => "1.013004";
requires "Rex::Helper::Run" => "0";
requires "Rex::Hook" => "0";
8 changes: 8 additions & 0 deletions lib/Rex/Hook/File/Diff.pm
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ use 5.012;
use warnings;

use File::Basename;
use IPC::Run;
use Rex 1.013004 -base;
use Rex::Helper::Run;
use Rex::Hook;
@@ -39,6 +40,13 @@ sub show_diff {
}

if ( length $diff > 0 ) {
my @highlighter = qw( delta --color-only --diff-so-fancy );
my $highlighted;

IPC::Run::run \@highlighter, \$diff, \$highlighted;

$diff = $highlighted;

Rex::Commands::say("Diff for: $original_file\n$diff");
}

0 comments on commit 0a61d1f

Please sign in to comment.