diff --git a/lib/datasource/cdnjs/index.spec.ts b/lib/datasource/cdnjs/index.spec.ts index db16b940c8dcbcdc8697c05be4409e20c23cd8d0..210f6dfcb9974f496f0044a78b22a399193de899 100644 --- a/lib/datasource/cdnjs/index.spec.ts +++ b/lib/datasource/cdnjs/index.spec.ts @@ -40,6 +40,12 @@ describe('datasource/cdnjs', () => { got.mockRejectedValueOnce({ statusCode: 404 }); expect(await getReleases({ lookupName: 'foo/bar' })).toBeNull(); }); + it('returns null for empty 200 OK', async () => { + got.mockResolvedValueOnce({ body: {} }); + expect( + await getReleases({ lookupName: 'doesnotexist/doesnotexist' }) + ).toBeNull(); + }); it('throws for 401', async () => { got.mockRejectedValueOnce({ statusCode: 401 }); await expect(getReleases({ lookupName: 'foo/bar' })).rejects.toThrowError( diff --git a/lib/datasource/cdnjs/index.ts b/lib/datasource/cdnjs/index.ts index c74c1d2e025ee0eb7394a29cc2b22017fa3f8d45..7354172a10957ee3514ddacc03a48d587327bcca 100644 --- a/lib/datasource/cdnjs/index.ts +++ b/lib/datasource/cdnjs/index.ts @@ -37,6 +37,9 @@ export async function getReleases({ lookup: library, cb: downloadLibrary, }); + if (!assets) { + return null; + } const assetName = lookupName.replace(`${library}/`, ''); const releases = assets .filter(({ files }) => files.includes(assetName))