Skip to content
Snippets Groups Projects
Commit 36afcad5 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix: handle invalid travis supportPolicy

parent 0abba43d
No related merge requests found
......@@ -21,13 +21,19 @@ async function getPackageUpdates(config) {
if (!(supportPolicy && supportPolicy.length)) {
supportPolicy = ['lts'];
}
for (const policy of supportPolicy) {
if (!Object.keys(policies).includes(policy)) {
logger.warn(`Unknown supportPolicy: ${policy}`);
return [];
}
}
logger.debug({ supportPolicy }, `supportPolicy`);
let newVersion = supportPolicy
.map(policy => policies[policy])
.reduce((result, policy) => result.concat(policy), [])
.sort() // sort combined array
.reverse() // we want to order latest to oldest
.map(version => `${version}`); // convert to strings
logger.debug({ newVersion });
if (config.pinVersions || semver.valid(config.currentVersion[0])) {
const releases = await getRepoReleases('nodejs/node');
newVersion = newVersion.map(version =>
......
......@@ -12,6 +12,11 @@ describe('lib/workers/package/node', () => {
...defaultConfig,
};
});
it('returns empty if invalid supportPolicy', async () => {
config.currentVersion = ['6', '8'];
config.supportPolicy = ['foo'];
expect(await node.getPackageUpdates(config)).toEqual([]);
});
it('returns empty if matching', async () => {
config.currentVersion = ['6', '8'];
config.supportPolicy = ['lts_active'];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment