[Rake-devel] [PATCH] clean.rb, directories

Daniel Berger djberg96 at gmail.com
Sun Feb 4 23:23:41 EST 2007


On 2/4/07, TRANS <transfire at gmail.com> wrote:
> On 2/4/07, Jim Weirich <jim at weirichhouse.org> wrote:
> > Daniel Berger wrote:
> > > Hi,
> > >
> > > This is a patch for the clean task, so that it only deletes files, not
> > > directories.
> > [...]
> > > This addresses an earlier email where someone brought up the fact that
> > > "rake clean" deletes a directory named 'core', not just core files.
> > > Since I hit it myself recently, I figure I should submit a patch. :)
> >
> > Thanks for the suggestion.  However, prohibiting CLEAN from deleting
> > directories feels like it is cutting off the arm to fix a hangnail.
> > CLEAN should be able to delete any temporary files created during a
> > build process, and that might include directories.
> >
> > I would rather see a solution targeted explicitly at the "core"
> > directory issue.
>
> Perhaps it would be a good time to bring this up. In setting up my
> rake tasks I've sort of took the opposite approach to CLEAN and
> created IGNORE. When building, say a package, I just have it include
> everything but what's in IGNORE, so there's no need to run 'clean'
> first.

That seems like a reasonable suggestion, and I don't think it's
mutually exclusive to dealing with directories named "core". We can do
both.

But, to deal with just the 'core' issue for now:

--- clean.orig  Sun Jun 06 00:51:00 2004
+++ clean.rb    Sun Feb 04 21:22:10 2007
@@ -20,7 +20,11 @@

 desc "Remove any temporary products."
 task :clean do
-  CLEAN.each { |fn| rm_r fn rescue nil }
+  CLEAN.each { |fn|
+    unless fn.downcase == 'core' && File.directory?(fn)
+      rm_r fn rescue nil
+    end
+  }
 end

 CLOBBER = Rake::FileList.new

Regards,

Dan


More information about the Rake-devel mailing list