Skip to content

Commit

Permalink
feat(sync): always ignore node_modules in sync mode
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Also includes an update to glob / minimatch. As
described in 378de99

> Since glob 6 removes support for comment and negation patterns, this may
> or may not be a breaking change from fileset's pov.
  • Loading branch information
mklabs committed Jun 1, 2016
1 parent d55cdf4 commit c6593c0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,14 @@ help:
bake -h

test:
node tests/test.js && node tests/test-sync.js
mocha -R spec test

eslint:
eslint .

fix:
eslint . --fix

old-tests:
node tests/test.js
node tests/test-sync.js
3 changes: 3 additions & 0 deletions lib/fileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ fileset.sync = function filesetSync(include, exclude) {
// - todo: pass in glob options as last param
var options = { matchBase: true };

// always ignore node_modules for sync api
options.ignore = ['node_modules/**/*'];

// First, glob match on all include patters into a single array
var results = includes.map(function(include) {
return glob.sync(include, options);
Expand Down
23 changes: 23 additions & 0 deletions test/mocha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var assert = require('assert');
var fileset = require('..');
var EventEmitter = require('events').EventEmitter;

describe('Sync API - Given a **.md pattern', function() {
it('returns the list of matching file in this repo', function() {
var results = fileset.sync('*.md', 'test/fixtures/**/*.md');
assert.ok(Array.isArray(results), 'should be an array');
assert.ok(results.length, 'should return at least one element');
assert.equal(results.length, 2, 'actually, should return only two');
});
});

describe('Sync API - Given a *.md and **.js pattern, and two exclude', function() {
it('returns the list of matching file in this repo', function() {
var results = fileset.sync('*.md *.js', 'CHANGELOG.md test/fixtures/**/*.md test/fixtures/**/*.js');

assert.ok(Array.isArray(results), 'should be an array');
assert.ok(results.length, 'should return at least one element');

assert.equal(results.length, 7, 'actually, should return only 7');
});
});

0 comments on commit c6593c0

Please sign in to comment.