diff --git a/ranges/index.js b/ranges/index.js index cf45e17..00ca6e8 100644 --- a/ranges/index.js +++ b/ranges/index.js @@ -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']; } } diff --git a/ranges/test/matrixAlias.test.js b/ranges/test/matrixAlias.test.js index 945db63..4ec7a41 100644 --- a/ranges/test/matrixAlias.test.js +++ b/ranges/test/matrixAlias.test.js @@ -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())); + }); }); diff --git a/ranges/test/singleAlias.test.js b/ranges/test/singleAlias.test.js index af95eed..0b1c5b8 100644 --- a/ranges/test/singleAlias.test.js +++ b/ranges/test/singleAlias.test.js @@ -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']); + }); });