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.');