fix: return empty travis updates if no support policy set

No longer defaults to supportPolicy=[‘lts’] when supportPolicy is undefined.

BREAKING CHANGE: If you wish to use travis with supportPolicy=lts, then you need to explicitly set that in node or travis config.
This commit is contained in:
Rhys Arkins 2018-04-09 08:29:39 +02:00
parent 1f63173194
commit e6e28a62fb
2 changed files with 8 additions and 2 deletions

View file

@ -17,9 +17,9 @@ const policies = {
async function getPackageUpdates(config) { async function getPackageUpdates(config) {
logger.debug('travis.getPackageUpdates()'); logger.debug('travis.getPackageUpdates()');
let { supportPolicy } = config; const { supportPolicy } = config;
if (!(supportPolicy && supportPolicy.length)) { if (!(supportPolicy && supportPolicy.length)) {
supportPolicy = ['lts']; return [];
} }
for (const policy of supportPolicy) { for (const policy of supportPolicy) {
if (!Object.keys(policies).includes(policy)) { if (!Object.keys(policies).includes(policy)) {

View file

@ -12,6 +12,10 @@ describe('lib/workers/package/node', () => {
...defaultConfig, ...defaultConfig,
}; };
}); });
it('returns empty if missing supportPolicy', async () => {
config.currentVersion = ['6', '8'];
expect(await node.getPackageUpdates(config)).toEqual([]);
});
it('returns empty if invalid supportPolicy', async () => { it('returns empty if invalid supportPolicy', async () => {
config.currentVersion = ['6', '8']; config.currentVersion = ['6', '8'];
config.supportPolicy = ['foo']; config.supportPolicy = ['foo'];
@ -24,10 +28,12 @@ describe('lib/workers/package/node', () => {
}); });
it('returns result if needing updates', async () => { it('returns result if needing updates', async () => {
config.currentVersion = ['6', '8']; config.currentVersion = ['6', '8'];
config.supportPolicy = ['lts'];
expect(await node.getPackageUpdates(config)).toMatchSnapshot(); expect(await node.getPackageUpdates(config)).toMatchSnapshot();
}); });
it('detects pinning', async () => { it('detects pinning', async () => {
config.currentVersion = ['6.1.0', '8.4.0']; config.currentVersion = ['6.1.0', '8.4.0'];
config.supportPolicy = ['lts'];
githubDatasource.getRepoReleases.mockReturnValueOnce([ githubDatasource.getRepoReleases.mockReturnValueOnce([
'v4.4.4', 'v4.4.4',
'v5.5.5', 'v5.5.5',