Skip to content

Instantly share code, notes, and snippets.

@Freezerburn
Created July 26, 2016 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Freezerburn/d9efbc524c927163e362ece5d7e9aaea to your computer and use it in GitHub Desktop.
Save Freezerburn/d9efbc524c927163e362ece5d7e9aaea to your computer and use it in GitHub Desktop.
my $filename = 'test.js';
my $grep-filename = filename($filename).comb.map({ '.*' ~ do $^a eq '.' ?? '\\.' !! $^a }).join ~ '.*\\.' ~ $filename.IO.extension ~ '$';
if not $grep-filename.starts-with('.*') {
$grep-filename = '.*' ~ $grep-filename;
}
$grep-filename.say;
my $grep-regex = /:i <$grep-filename>/;
# Paths are anonymized to just have magic variables in them.
my $src-path = "$SOURCE-PATH";
my $dst-path = "$DEST-PATH";
my @dir-stack = "$START-PATH".IO;
my @swap-list;
while @dir-stack.elems {
my $cur = pop @dir-stack;
for $cur.dir -> $next {
if $next.d {
push @dir-stack, $next;
}
elsif $next.basename ~~ $grep-regex {
push @swap-list, $next;
}
}
}
@swap-list.say;
#Will eventually look in dst for a file that matches files in swap-list and copy the source files over the dest ones.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment