Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

FileList should support globstar #115

Closed
jamesshore opened this Issue · 14 comments

3 participants

@jamesshore

Including a globstar in a file list [files.include('./example/**/*.js');] causes a ENOENT error. It should instead recursively include subdirectories.

Jakefile reproducing the problem follows:

var fs = require("fs");

var exampleRootDir = "./example";
var exampleNestedDir = exampleRootDir + "/a";
var shallowFile = exampleRootDir + "/shallow.js";
var deepFile = exampleNestedDir + "/deep.js";

desc("Demonstrate the globstar bug");
task("default", [deepFile, shallowFile], function() {
        var files = new jake.FileList();
        files.include('./example/**/*.js');
        console.log("File list should be: ", [shallowFile, deepFile]);
        console.log("File list is actually: ", files.toArray());    // jake aborts here with ENOENT error
});

desc("Create a shallowly-nested file");
file(shallowFile, [exampleRootDir], function() {
        fs.writeFileSync(shallowFile, "This is a shallowly-nested file");
        console.log("Created file at " + shallowFile);
});

desc("Create a deeply-nested file");
file(deepFile, [exampleNestedDir], function() {
        fs.writeFileSync(deepFile, "This is a deeply-nested file");
        console.log("Created file at " + deepFile);
});

directory(exampleNestedDir, [exampleRootDir]);
directory(exampleRootDir);
@kuon

Minimatch seems to support globstart, I'm surprised Jake doesn't.

@mde
Owner

Yes, this is surprising since Jake actually uses Minimatch to build the list. I'll have to dig deeper to see what's happening here.

@mde
Owner

This is fixed in master. Please reopen if it's not working as expected.

@mde mde closed this
@kuon

Still not working:

Error: ENOENT, no such file or directory 'lib/**'

with

list.include('lib/**/*');

It seems that:

, files = jake.readdirR(dirname)

in file_list.js:25 is actually doing

, files = jake.readdirR('lib/**')

which fails.

@mde
Owner

Excellent, thanks. I'll fix this ASAP, add some tests for this as well.

@mde mde reopened this
@mde
Owner

Yes, looks like path.dirname couldn't handle the globstar. My somewhat hacky solution is now in master -- can somebody verify this works as expected?

@mde
Owner

Please reopen if this isn't fixed. :)

@mde mde closed this
@kuon
@mde mde reopened this
@mde
Owner

Can you check master and see if things work as you expect now? There's a jake.basedir command in the file utilities now which should do the right thing in all the cases I could think of. Tests are in tests/file_utils.js. If it's all good, I'll publish a new version with the fix.

@kuon

Seems to work for me with master.

@mde
Owner

Huzzah! Thanks for the sanity-check, and for filing such high-quality bugs!

@mde mde closed this
@kuon

It seems that '*.j' cause problem:

In my jakefile:

 sourcePaths.include('*.j');

results in:

Error: ENOENT, no such file or directory '.j'
at Object.readdirSync (fs.js:398:18)

@mde
Owner

Okay, I've added a fix and test for this in master. I'll publish as soon as you verify. :)

@kuon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.