File: mk_regexp

package info (click to toggle)
pkg-js-tools 0.16.0
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,992 kB
  • sloc: perl: 4,975; sh: 840; makefile: 36; javascript: 22
file content (60 lines) | stat: -rwxr-xr-x 1,816 bytes parent folder | download | duplicates (4)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl -i -p

use strict;
use Regexp::Assemble;
our ( $expr, $expr2, $dexpr, $makefiles, $webpacks, $docFiles, $changelogs );

sub open_file {
    my ($file) = @_;
    my @res;
    open F, '<', $file or die $!;
    while ( my $l = <F> ) {
        chomp $l;
        next if ( $l =~ /^\s*#/ );
        next if $l =~ /^\s*$/;
        push @res, $l;
    }
    return @res;
}

BEGIN {
    my $re   = Regexp::Assemble->new;
    my $remk = Regexp::Assemble->new;
    $re->add($_) foreach ( open_file('dh_nodejs/dh_root_files.excluded') );
    foreach ( open_file('dh_nodejs/dh_makefiles') ) {
        $re->add($_);
        $remk->add($_);
    }
    $expr      = $re->as_string;
    $makefiles = $remk->as_string;

    $re = Regexp::Assemble->new;
    $re->add($_) foreach ( open_file('dh_nodejs/dh_files.excluded') );
    $expr2 = $re->as_string;

    $re = Regexp::Assemble->new;
    $re->add($_) foreach ( open_file('dh_nodejs/dh_dirs.excluded') );
    $dexpr = $re->as_string;

    $re = Regexp::Assemble->new;
    $re->add($_) foreach ( open_file('dh_nodejs/dh_webpacks') );
    $webpacks = $re->as_string;

    $re = Regexp::Assemble->new;
    $re->add($_) foreach ( open_file('dh_nodejs/dh_docs') );
    $docFiles = $re->as_string;

    $re = Regexp::Assemble->new;
    $re->add($_) foreach ( open_file('dh_nodejs/dh_changelogs') );
    $changelogs = $re->as_string;

}
$/ = ';';

s#qr.*$#qr/^$expr\$/i;#s                 if /my \$rootFilesIgnored/;
s#qr.*$#qr/^$expr2\$/i;#s                if /my \$filesIgnored/;
s#qr.*$#qr\{^$dexpr(?:/.*)?$\}i;#s       if /my \$dirIgnored/;
s#qr.*$#qr/^\.\*\\b$webpacks\\b\.\*/i;#s if /my \$WEBPACKS/;
s#qr.*$#qr/^$docFiles\$/i;#s             if /my \$DOCFILES/;
s#qr.*$#qr/^$changelogs\$/i;#s           if /my \$CHANGELOGS/;
s#(MAKEFILES=').*?('\n)#$1\^$makefiles\$$2#;