Skip to content

Commit c6593c0

Browse files
committed
feat(sync): always ignore node_modules in sync mode
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.
1 parent d55cdf4 commit c6593c0

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,14 @@ help:
55
bake -h
66

77
test:
8-
node tests/test.js && node tests/test-sync.js
8+
mocha -R spec test
9+
10+
eslint:
11+
eslint .
12+
13+
fix:
14+
eslint . --fix
15+
16+
old-tests:
17+
node tests/test.js
18+
node tests/test-sync.js

lib/fileset.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ fileset.sync = function filesetSync(include, exclude) {
6363
// - todo: pass in glob options as last param
6464
var options = { matchBase: true };
6565

66+
// always ignore node_modules for sync api
67+
options.ignore = ['node_modules/**/*'];
68+
6669
// First, glob match on all include patters into a single array
6770
var results = includes.map(function(include) {
6871
return glob.sync(include, options);

test/mocha.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var assert = require('assert');
2+
var fileset = require('..');
3+
var EventEmitter = require('events').EventEmitter;
4+
5+
describe('Sync API - Given a **.md pattern', function() {
6+
it('returns the list of matching file in this repo', function() {
7+
var results = fileset.sync('*.md', 'test/fixtures/**/*.md');
8+
assert.ok(Array.isArray(results), 'should be an array');
9+
assert.ok(results.length, 'should return at least one element');
10+
assert.equal(results.length, 2, 'actually, should return only two');
11+
});
12+
});
13+
14+
describe('Sync API - Given a *.md and **.js pattern, and two exclude', function() {
15+
it('returns the list of matching file in this repo', function() {
16+
var results = fileset.sync('*.md *.js', 'CHANGELOG.md test/fixtures/**/*.md test/fixtures/**/*.js');
17+
18+
assert.ok(Array.isArray(results), 'should be an array');
19+
assert.ok(results.length, 'should return at least one element');
20+
21+
assert.equal(results.length, 7, 'actually, should return only 7');
22+
});
23+
});

0 commit comments

Comments
 (0)