Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

chore!: Drop support for ordered globs #115

Merged
merged 2 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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