Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes for FileList support.

Reviewed by me.
  • Loading branch information...
commit 68a8fd100e4b7a2fe7ce427bceb078c767bf1ea1 1 parent 7aa6e34
@tolmasky tolmasky authored
Showing with 24 additions and 10 deletions.
  1. +2 −0  lib/jake.js
  2. +20 −8 lib/jake/filelist.js
  3. +2 −2 lib/jake/task.js
View
2  lib/jake.js
@@ -660,6 +660,8 @@ exports.filedir = function()
exports.directory (fileDirectory);
exports.file (fileTask.name(), fileDirectory);
}
+
+exports.FileList = require("jake/filelist").FileList;
/*
# Return the original directory where the Rake application was started.
def original_dir
View
28 lib/jake/filelist.js
@@ -106,7 +106,7 @@ function FileList(/*Strings, vararg*/)
this._excludedProcs = DEFAULT_IGNORE_PROCS.slice();
this._items = [];
- Array.prototype.forEach.apply(arguments, function(anArgument)
+ Array.prototype.forEach.call(arguments, function(anArgument)
{
this.include(anArgument);
}, this);
@@ -185,7 +185,7 @@ FileList.prototype.add = FileList.prototype.include;
//
FileList.prototype.exclude = function(/*Strings|Functions*/)
{
- Array.prototype.forEach.apply(arguments, function(/*String|Function*/ anObject)
+ Array.prototype.forEach.call(arguments, function(/*String|Function*/ anObject)
{
if (typeof anObject === "function")
this._excludedProcs.push(anObject);
@@ -278,15 +278,27 @@ FileList.prototype._resolveExclude = function()
FileList.prototype._shouldExclude = function(aFilename)
{
- var failedFilters = this._excludedPatterns.filter(function(aPattern){
- return aPattern.test(aFilename);
- }, this);
+ return this._excludedPatterns.some(function(aPattern)
+ {
+ if (aPattern.constructor === RegExp && aPattern.test(aFilename))
+ return true;
+
+ if (aPattern.match && aPattern.match(/[*?]/))
+ {
+ var OS = require("os");
- var failedProcs = this._excludedProcs.filter(function(aFunction){
+ OS.system("echo \"puts File.fnmatch?(" + OS.enquote(aPattern) + ", " + OS.enquote(aFilename) + ", File::FNM_PATHNAME)\" | ruby > /tmp/fnmatch_fixme.txt");
+
+ return FILE.read("/tmp/fnmatch_fixme.txt", {charsert:"UTF-8"}).indexOf("true") !== -1;
+ }
+
+ if (aFilename === aPattern)
+ return true;
+ }) ||
+ this._excludedProcs.some(function(aFunction)
+ {
return aFunction.apply(this, [aFilename]);
}, this);
-
- return (failedFilters.length !== 0 || failedProcs.length !== 0);
}
/*
View
4 lib/jake/task.js
@@ -64,10 +64,10 @@ Task.prototype.application = function()
return this._application;
}
-Task.prototype.enhance = function(/*Array*/ prerequisites, /*Function*/ anAction)
+Task.prototype.enhance = function(/*Array|FileList*/ prerequisites, /*Function*/ anAction)
{
if (prerequisites)
- this._prerequisites = this._prerequisites.concat(prerequisites);
+ this._prerequisites = this._prerequisites.concat(prerequisites.toArray ? prerequisites.toArray() : prerequisites);
if (anAction)
this._actions.push(anAction);
Please sign in to comment.
Something went wrong with that request. Please try again.