Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

npm-update

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-update - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

26

lib/npm-update.js

@@ -22,4 +22,8 @@ 'use strict';

const protocol = options.protocol || 'http';
const host = options.host || 'registry.cnpmjs.org';
const host = options.host || 'registry.npmjs.org';
const version = typeof options.version !== 'undefined' ? options.version : 'latest';
let silent = false;
if (typeof options.silent !== 'undefined') {
silent = options.silent;
}

@@ -41,12 +45,14 @@ const url = `${protocol}://${host}/${packageName}/${version}`;

if (semver.gt(latestVersion, packageVersion)) {
console.log(boxen(
`new version ${chalk.cyan(latestVersion)} found
if (!silent) {
console.log(boxen(
`new version ${chalk.cyan(latestVersion)} found
run ${chalk.cyan(`npm i webpack-seed-project@${semver.major(latestVersion)} -g`)}`,
{
padding: 1,
borderStyle: 'round',
borderColor: 'cyan',
}
));
run ${chalk.cyan(`npm i ${packageName}@${semver.major(latestVersion)} -g`)}`,
{
padding: 1,
borderStyle: 'round',
borderColor: 'cyan',
}
));
}
return {

@@ -53,0 +59,0 @@ needUpdate: true,

{
"name": "npm-update",
"version": "2.0.0",
"version": "2.1.0",
"description": "npm update",

@@ -5,0 +5,0 @@ "keywords": [

@@ -41,3 +41,3 @@ # npm-update

If `needUpdate` is `true`, outlog this message:
If `needUpdate` is `true`, print message:

@@ -54,2 +54,18 @@ ```

## Options
```javascript
const {
needUpdate, // return true | false
version: latestVersion, // return version if needUpdate
} = await update(options)
```
- options {object}
- **pkg** {object} package.json object.
- **host** {String} registry host, default is **registry.npmjs.org**.
- **timeout** {Number} request registry timeout, default is **3000ms**.
- **version** {String} base version for comparing, can be npm tag or npm version, default is **latest**.
- **silent** {Boolean} if slient is true, will not print message, default is false.
<!-- GITCONTRIBUTOR_START -->

@@ -56,0 +72,0 @@

@@ -16,2 +16,3 @@ 'use strict';

version: '0.1',
host: 'registry.cnpmjs.org',
});

@@ -29,2 +30,3 @@ assert.deepStrictEqual(res, {

},
host: 'registry.cnpmjs.org',
});

@@ -44,2 +46,3 @@ assert.deepStrictEqual(res, {

version: '2',
host: 'registry.cnpmjs.org',
});

@@ -57,2 +60,3 @@ assert(res.needUpdate === true);

version: 'next',
host: 'registry.cnpmjs.org',
});

@@ -70,2 +74,3 @@ assert(res.needUpdate === true);

version: '0.1',
host: 'registry.cnpmjs.org',
});

@@ -90,2 +95,3 @@ assert(res.needUpdate === false);

},
host: 'registry.cnpmjs.org',
});

@@ -102,2 +108,3 @@ assert.fail();

},
host: 'registry.cnpmjs.org',
});

@@ -109,2 +116,16 @@ assert.fail();

});
it('silent mode', function * () {
const res = yield update({
pkg: {
name: 'macaca-datahub',
version: '2.0.0',
},
version: 'next',
host: 'registry.cnpmjs.org',
silent: true,
});
assert(res.needUpdate === true);
assert(res.version);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc