diff --git a/src/plugins/default/__tests__/updates.js b/src/plugins/default/__tests__/updates.js new file mode 100644 index 00000000..bb1ef177 --- /dev/null +++ b/src/plugins/default/__tests__/updates.js @@ -0,0 +1,10 @@ +import { describe, it } from 'mocha'; +import { checkPackageUpdates } from '../../../updates'; +import { expect } from 'chai'; + +describe.only('package updates', () => { + it('should detect update', async () => { + const result = await checkPackageUpdates('mup', {version: '1.0.0'}); + expect(result).to.equal(true); + }); +}); diff --git a/src/updates.js b/src/updates.js index a524966a..88b9cdca 100644 --- a/src/updates.js +++ b/src/updates.js @@ -74,7 +74,7 @@ function showUpdateOnExit(pkg, version, isStable) { }); } -function checkPackageUpdates(name, pkg) { +export function checkPackageUpdates(name, pkg) { log(`retrieving tags for ${name}`); return axios.get(`https://registry.npmjs.org/-/package/${name}/dist-tags`) @@ -95,6 +95,8 @@ function checkPackageUpdates(name, pkg) { if (available) { showUpdateOnExit(pkg, isStable ? npmVersion : nextVersion, isStable); } + + return Boolean(available); }).catch(e => { // It is okay if this fails log(e);