Skip to content

Commit

Permalink
chore!: Drop support for ordered globs (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
phated authored Nov 16, 2022
1 parent 156f801 commit f37bccc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 46 deletions.
22 changes: 3 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ function globStream(globs, opt) {
var glob = isNegatedGlob(globString);
var globArray = glob.negated ? negatives : positives;

globArray.push({
index: index,
glob: glob.pattern,
});
globArray.push(glob.pattern);
}

if (positives.length === 0) {
Expand All @@ -74,22 +71,9 @@ function globStream(globs, opt) {
return pumpify.obj(aggregate, uniqueStream);

function streamFromPositive(positive) {
var negativeGlobs = negatives
.filter(indexGreaterThan(positive.index))
.map(toGlob)
.concat(ignore);
return new GlobStream(positive.glob, negativeGlobs, ourOpt);
var negativeGlobs = negatives.concat(ignore);
return new GlobStream(positive, negativeGlobs, ourOpt);
}
}

function indexGreaterThan(index) {
return function (obj) {
return obj.index > index;
};
}

function toGlob(obj) {
return obj.glob;
}

module.exports = globStream;
30 changes: 3 additions & 27 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,39 +548,15 @@ describe('glob-stream', function () {
);
});

it('respects order of negative globs', function (done) {
var expected = {
cwd: dir,
base: dir + '/fixtures/stuff',
path: dir + '/fixtures/stuff/run.dmc',
};

it('applies all negative globs to each positive glob', function (done) {
var globs = [
'./fixtures/stuff/*',
'!./fixtures/stuff/*.dmc',
'./fixtures/stuff/run.dmc',
'./fixtures/stuff/*.dmc',
];

function assert(pathObjs) {
expect(pathObjs.length).toEqual(1);
expect(pathObjs[0]).toEqual(expected);
}

pipe([globStream(globs, { cwd: dir }), concat(assert)], done);
});

it('ignores leading negative globs', function (done) {
var expected = {
cwd: dir,
base: dir + '/fixtures/stuff',
path: dir + '/fixtures/stuff/run.dmc',
};

var globs = ['!./fixtures/stuff/*.dmc', './fixtures/stuff/run.dmc'];

function assert(pathObjs) {
expect(pathObjs.length).toEqual(1);
expect(pathObjs[0]).toEqual(expected);
expect(pathObjs.length).toEqual(0);
}

pipe([globStream(globs, { cwd: dir }), concat(assert)], done);
Expand Down

0 comments on commit f37bccc

Please sign in to comment.