Skip to content

Commit

Permalink
Adds rm-cache back
Browse files Browse the repository at this point in the history
Related to #10. Also adds tests to avoid accidental removal.
  • Loading branch information
JJ committed Sep 30, 2019
1 parent 95182bf commit 0c06ddc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lib/Pod/To/Cached.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ method freeze( --> Bool ) {
self.save-index;
}

sub rm-cache( $path ) is export {
if $*SPEC ~~ IO::Spec::Win32 {
my $win-path = "$*CWD/$path".trans( ["/"] => ["\\"] );
shell "rmdir /S /Q $win-path" ;
} else {
shell "rm -rf $path";
}
}

=begin pod
=TITLE Pod::To::Cached
Expand Down Expand Up @@ -373,4 +382,8 @@ $cache.freeze;
=defn Old
A source name that is in the cache but no longer reflects an existing source.
=item rm-cache
Deletes the whole directory tree that holds the cache in an OS-independent way.
=end pod
5 changes: 4 additions & 1 deletion t/030-sub-directories.t
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ nok 'sub-dir-1' ~~ any( $cache.hash-files.keys ), 'sub-directories filtered from
't'.IO.&indir( {$cache .= new(:source( 'tmp/doc' ) ) } );
#--MARKER-- Test 4
ok 't/.pod-cache'.IO ~~ :d, 'default repository created';

# clean up
rmtree 't/.pod-cache';
rm-cache 't/.pod-cache';
nok 't/.pod-cache'.IO ~~ :d, 'Default directory removed';

done-testing;

0 comments on commit 0c06ddc

Please sign in to comment.