From d9ef722ee974943935258fe0104b2fc06e179191 Mon Sep 17 00:00:00 2001 From: Steve Terpe Date: Tue, 18 Mar 2014 12:08:01 -0700 Subject: [PATCH] Fix issue with globbing exclusions against relative filepaths --- lib/globule.js | 4 ++-- test/globule_test.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/globule.js b/lib/globule.js index 5a3eeac..5a904ff 100644 --- a/lib/globule.js +++ b/lib/globule.js @@ -31,9 +31,9 @@ function processPatterns(patterns, options, fn) { } // The first character is ! (exclusion). Remove any filepaths from the // result set that match this pattern, sans leading !. - var filterFn = minimatch.filter(pattern.slice(1), options); + var filterFn = minimatch.filter(path.resolve(pattern.slice(1)), options); result = _.filter(result, function(filepath) { - return !filterFn(filepath); + return !filterFn(path.resolve(filepath)); }); }); return result; diff --git a/test/globule_test.js b/test/globule_test.js index 4b921ea..31ad19e 100644 --- a/test/globule_test.js +++ b/test/globule_test.js @@ -209,6 +209,13 @@ exports['find'] = { 'inclusion / exclusion order matters'); test.done(); }, + 'exclusion against relative paths': function (test) { + test.expect(1); + test.deepEqual(globule.find('../../fixtures/expand/js/*.js', 'css/**/*.css', '!**/js/**', '!**/css/**/qux.css'), [ + 'css/baz.css'], + 'exclusion rules should be properly evaluated against relative filepaths'); + test.done(); + }, 'options.src': function(test) { test.expect(4); test.deepEqual(globule.find({src: '**/*.js'}), ['js/bar.js', 'js/foo.js'], 'single pattern argument should match.');