Files

Return to Package Diff Home.
Brought to you by Intrinsic.

Package Diff: npm-check-updates @ 3.1.3 .. 3.1.9

lib/npm-check-updates.js

@@ -107,7 +107,7 @@
const table = createDependencyTable();
const rows = Object.keys(args.to).map(dep => {
const from = args.from[dep] || '';
- const to = versionUtil.colorizeDiff(args.to[dep] || '', args.from[dep]);
+ const to = versionUtil.colorizeDiff(args.from[dep], args.to[dep] || '');
return [dep, from, '→', to];
});
rows.forEach(row => table.push(row));
@@ -382,6 +382,11 @@
/** main entry point */
async function run(options={}) {
+ // exit with non-zero error code when there is an unhandled promise rejection
+ process.on('unhandledRejection', err => {
+ throw err;
+ });
+
// if not executed on the command-line (i.e. executed as a node module), set some defaults
if (!options.cli) {
options = _.defaults({}, options, {

lib/package-managers/npm.js

@@ -6,6 +6,22 @@
const versionUtil = require('../version-util.js');
const spawn = require('spawn-please');
const packageJson = require('package-json');
+const npmConf = require('npm-conf')();
+const {Agent: HttpAgent} = require('http');
+const {Agent: HttpsAgent} = require('https');
+
+const httpAgentOptions = {
+ keepAlive: true,
+ maxSockets: npmConf.get('maxsockets')
+};
+const httpsAgentOptions = Object.assign({
+ ca: npmConf.get('ca'),
+ key: npmConf.get('key'),
+ cert: npmConf.get('cert'),
+ rejectUnauthorized: npmConf.get('strict-ssl')
+}, httpAgentOptions);
+const httpAgent = new HttpAgent(httpAgentOptions);
+const httpsAgent = new HttpsAgent(httpsAgentOptions);
const {getProxyAgent} = require('./npm-proxy');
@@ -39,6 +55,11 @@
const proxyAgent = getProxyAgent(scope);
if (proxyAgent) {
options.agent = proxyAgent;
+ } else {
+ options.agent = {
+ http: httpAgent,
+ https: httpsAgent
+ };
}
if (field === 'time') {

lib/package-managers/npm-proxy.js

@@ -41,10 +41,10 @@
if (proxyUrl) {
const proxy = global.URL ? new URL(proxyUrl) : url.parse(proxyUrl);
proxyAgent = new ProxyAgent({
+ protocol: proxy.protocol,
host: proxy.hostname,
port: proxy.port,
- secureProxy: proxy.protocol === 'https:',
- keepAlive: true,
+ auth: global.URL ? proxy.username + (proxy.password ? ':' + proxy.password : '') : proxy.auth,
maxSockets: npmConf.get('maxsockets'),
ca: npmConf.get('ca'),
key: npmConf.get('key'),

lib/versionmanager.js

@@ -252,7 +252,7 @@
for (const dependency in newDependencies) {
if (!options.minimal || !isSatisfied(newVersions[dependency], oldDependencies[dependency])) {
if (options.interactive) {
- const to = versionUtil.colorizeDiff(newDependencies[dependency] || '', oldDependencies[dependency]);
+ const to = versionUtil.colorizeDiff(oldDependencies[dependency], newDependencies[dependency] || '');
const response = await prompts({
type: 'confirm',
name: 'value',
@@ -426,11 +426,7 @@
)
);
- // if none of the dependencies use a wildcard, return null
- const usedWildcards = Object.keys(groups);
- if (usedWildcards.length === 1 && usedWildcards[0] === 'undefined') {
- return null;
- }
+ delete groups.undefined;
// convert to an array of objects that can be sorted
const arrOfGroups = cint.toArray(groups, (wildcard, instances) => ({
@@ -441,7 +437,7 @@
// reverse sort the groups so that the wildcard with the most appearances is at the head, then return it.
const sorted = _.sortBy(arrOfGroups, wildcardObject => -wildcardObject.instances.length);
- return sorted[0].wildcard;
+ return sorted.length > 0 ? sorted[0].wildcard : null;
}
function getVersionTarget(options) {

lib/version-util.js

@@ -113,30 +113,29 @@
}
/**
- * Colorize the parts of a version string that are different than a given string to compare to. Assumes that the two
- * verson strings are in the same format.
+ * Colorize the parts of a version string (to) that are different than another (from). Assumes that the two verson strings are in the same format.
*/
-function colorizeDiff(strToColor, strToCompare) {
+function colorizeDiff(from, to) {
let leadingWildcard = '';
// separate out leading ^ or ~
- if (/^[~^]/.test(strToColor) && strToColor[0] === strToCompare[0]) {
- leadingWildcard = strToColor[0];
- strToColor = strToColor.slice(1);
- strToCompare = strToCompare.slice(1);
+ if (/^[~^]/.test(to) && to[0] === from[0]) {
+ leadingWildcard = to[0];
+ to = to.slice(1);
+ from = from.slice(1);
}
// split into parts
- const partsToColor = strToColor.split('.');
- const partsToCompare = strToCompare.split('.');
+ const partsToColor = to.split('.');
+ const partsToCompare = from.split('.');
let i = _.findIndex(partsToColor, (part, i) => part !== partsToCompare[i]);
i = i >= 0 ? i : partsToColor.length;
- // major = red
+ // major = red (or any change before 1.0.0)
// minor = cyan
// patch = green
- const color = i === 0 ? 'red' :
+ const color = i === 0 || partsToColor[0] === '0' ? 'red' :
i === 1 ? 'cyan' :
'green';

package.json

@@ -1,6 +1,6 @@
{
"name": "npm-check-updates",
- "version": "3.1.3",
+ "version": "3.1.9",
"author": "Tomas Junnonen <tomas1@gmail.com>",
"license": "Apache-2.0",
"contributors": [