Skip to content
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
16 changes: 10 additions & 6 deletions ranges/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,18 @@ async function generateRanges(filter, options) {
}
}

// make sure we remove any unrequested remnants from lts/active construction
if (Array.isArray(localFilter) && localFilter.includes('lts/active')) {
if (!localFilter.includes('lts/latest')) {
ranges['lts/latest'] = undefined;
// make sure we remove any unrequested remnants from lts/active construction.
// a string filter is checked as a one-item list, since `includes` on a
// string matches substrings
const requested = [localFilter].flat();

if (requested.includes('lts/active') && !requested.includes('all')) {
if (!requested.includes('lts/latest')) {
delete ranges['lts/latest'];
}

if (!localFilter.includes('lts/maintenance')) {
ranges['lts/maintenance'] = undefined;
if (!requested.includes('lts/maintenance')) {
delete ranges['lts/maintenance'];
}
}

Expand Down
5 changes: 5 additions & 0 deletions ranges/test/matrixAlias.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,9 @@ describe('data should exist as it is defined when calling multiple aliases', asy
assert.deepStrictEqual(data.all, undefined);
assert.deepStrictEqual(data['lts/latest'], undefined);
});

it('every range should be present if an array with "all" and "lts/active" is passed', async () => {
const data = await ranges(['all', 'lts/active'], at());
assert.deepStrictEqual(data, await ranges('all', at()));
});
});
5 changes: 5 additions & 0 deletions ranges/test/singleAlias.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,9 @@ describe('data should exist as it is defined when calling a single alias', async
true,
);
});

it('only "lts/active" should be present if the string "lts/active" is passed', async () => {
const data = await ranges('lts/active', at());
assert.deepStrictEqual(Object.keys(data), ['lts/active']);
});
});
Loading