Permalink
Browse files

Added clean and clobber support.

Reviewed by me.
  • Loading branch information...
1 parent e11a66b commit c3e449073ae8686fee0785431f2a8de6baff7025 @tolmasky tolmasky committed Oct 26, 2009
Showing with 30 additions and 14 deletions.
  1. +30 −14 lib/jake/clean.js
View
@@ -1,5 +1,3 @@
-#!/usr/bin/env narwhal
-
// Copyright 2009 280 North, Inc. (francisco@280north.com)
// Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by Jim Weirich (jim.weirich@gmail.com)
//
@@ -36,31 +34,49 @@
// The intent of this task is to return a project to its
// pristine, just unpacked state.
-var Jake = require("jake");
+var FILE = require("file"),
+ Jake = require("jake"),
+ FileList = require("jake/filelist").FileList;
+
+
+var CLEAN = new FileList("**/*~", "**/*.bak", "**/core");
-CLEAN = [];//new Jake.FileList("**/*~", "**/*.bak", "**/core");
-/*
CLEAN.clearExclude().exclude(function(aFilename)
{
- aFilename.pathmap("%f") == 'core' && File.directory?(fn)
-});*/
+ return FILE.basename(aFilename) === "core" && FILE.isDirectory(aFilename);
+});
-//desc "Remove any temporary products."
-task ("clean", function()
+// desc "Remove any temporary products."
+Jake.task("clean", function()
{
CLEAN.forEach(function(aFilename)
{
- FILE.rmTree(aFilename);
+ try
+ {
+ FILE.rmtree(aFilename);
+ }
+ catch(anException)
+ {
+ }
});
});
-CLOBBER = new Jake::FileList;
+var CLOBBER = new Jake.FileList();
-//desc "Remove any generated file."
-task ("clobber", ["clean"], function()
+// desc "Remove any generated file."
+task("clobber", ["clean"], function()
{
CLOBBER.forEach(function(aFilename)
{
- FILE.rmTree(aFilename);
+ try
+ {
+ FILE.rmtree(aFilename);
+ }
+ catch(anException)
+ {
+ }
});
});
+
+exports.CLEAN = CLEAN;
+exports.CLOBBER = CLOBBER;

0 comments on commit c3e4490

Please sign in to comment.