Skip to content

Commit 0c06ddc

Browse files
committed
Adds rm-cache back
Related to #10. Also adds tests to avoid accidental removal.
1 parent 95182bf commit 0c06ddc

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/Pod/To/Cached.pm6

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ method freeze( --> Bool ) {
261261
self.save-index;
262262
}
263263

264+
sub rm-cache( $path ) is export {
265+
if $*SPEC ~~ IO::Spec::Win32 {
266+
my $win-path = "$*CWD/$path".trans( ["/"] => ["\\"] );
267+
shell "rmdir /S /Q $win-path" ;
268+
} else {
269+
shell "rm -rf $path";
270+
}
271+
}
272+
264273
=begin pod
265274
266275
=TITLE Pod::To::Cached
@@ -373,4 +382,8 @@ $cache.freeze;
373382
=defn Old
374383
A source name that is in the cache but no longer reflects an existing source.
375384
385+
=item rm-cache
386+
387+
Deletes the whole directory tree that holds the cache in an OS-independent way.
388+
376389
=end pod

t/030-sub-directories.t

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ nok 'sub-dir-1' ~~ any( $cache.hash-files.keys ), 'sub-directories filtered from
3636
't'.IO.&indir( {$cache .= new(:source( 'tmp/doc' ) ) } );
3737
#--MARKER-- Test 4
3838
ok 't/.pod-cache'.IO ~~ :d, 'default repository created';
39+
3940
# clean up
40-
rmtree 't/.pod-cache';
41+
rm-cache 't/.pod-cache';
42+
nok 't/.pod-cache'.IO ~~ :d, 'Default directory removed';
43+
4144
done-testing;

0 commit comments

Comments
 (0)