Skip to content

Commit

Permalink
Add basic updates test
Browse files Browse the repository at this point in the history
  • Loading branch information
zodern committed Oct 7, 2024
1 parent 15e0425 commit 22f8ef4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/plugins/default/__tests__/updates.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
4 changes: 3 additions & 1 deletion src/updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand All @@ -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);
Expand Down

0 comments on commit 22f8ef4

Please sign in to comment.