-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.pl
39 lines (29 loc) · 896 Bytes
/
build.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use strict;
use warnings;
use Term::ANSIColor qw(:constants);
use Text::Diff;
require "./main.pl";
our ($expanded, $collapsed);
# remove the wrappings from qr//
my $pattern = $expanded =~ s/(^\(\?\^x\:\n+|\n+\)$)//rg;
# remove any whole single line comments (at ANY indent)
$pattern =~ s/\n([ \t]*[#][^\n]+\n)+/\n/g;
# remove any indents
$pattern =~ s/^[ \t]*//gm;
# remove rest of newlines
$pattern =~ s/\n//g;
my %options = (
STYLE => "Unified",
OUTPUT => \*STDOUT,
FILENAME_A => 'Existing',
FILENAME_B => 'New'
);
# get existing collapsed pattern to compare against
my $expected = $collapsed =~ s/(^\(\?\^x\:\n+|\n+\)$)//rg;
if ($expected eq $pattern) {
print BRIGHT_GREEN ON_BLACK "No changes detected!\n", RESET;
} else {
print BRIGHT_RED ON_BLACK "Differences detected:\n", RESET;
diff \$expected, \$pattern, \%options;
}
print "\nCompiled pattern:\n\n$pattern\n\n";