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

package-age

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

package-age - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

31

index.js

@@ -10,3 +10,3 @@ #!/usr/bin/env node

const config = {
version: '0.1.3',
version: '0.1.4',
registry: 'https://registry.npmjs.org/',

@@ -72,20 +72,29 @@ cli: true,

function process(dependencies, type) {
async function process(dependencies, type) {
const packages = [];
for (const dependency in dependencies) {
if (dependencies.hasOwnProperty(dependency)) {
const version = dependencies[dependency];
info(dependency, Versions.clean(version), type);
const output = await info(dependency, Versions.clean(version), type);
packages.push(output);
}
}
if (packages.length > 0) {
console.log(packages.join('\n'), '\n'); // eslint-disable-line no-console
}
}
function info(name, version, type) {
request(`${config.registry}${name}`).then((body) => {
const v = Versions.compare(version, body['dist-tags'].latest);
const d = Dates.compare(body.time[version]);
if (type === Types.NORMAL) {
console.log(name, v, d);// eslint-disable-line no-console
} else {
console.log(name, Types.short[type], v, d);// eslint-disable-line no-console
}
return new Promise((resolve, reject) => {
request(`${config.registry}${name}`).then((body) => {
const v = Versions.compare(version, body['dist-tags'].latest);
const d = Dates.compare(body.time[version]);
if (type === Types.NORMAL) {
resolve(`${name} ${v} ${d}`);
} else {
resolve(`${name} ${Types.short[type]} ${v} ${d}`);
}
}).catch((error) => {
reject(error);
});
});

@@ -92,0 +101,0 @@ }

{
"name": "package-age",
"version": "0.1.3",
"version": "0.1.4",
"description": "A CLI for detecting old dependencies used in your project",

@@ -8,4 +8,4 @@ "main": "index.js",

"chalk": "^2.4.1",
"commander": "^2.15.1",
"read-pkg": "^3.0.0",
"commander": "^2.16.0",
"read-pkg": "^4.0.1",
"semver": "^5.5.0"

@@ -15,3 +15,3 @@ },

"chai": "^4.1.2",
"eslint": "^4.19.1",
"eslint": "^5.0.1",
"mocha": "^5.2.0"

@@ -18,0 +18,0 @@ },

@@ -17,5 +17,5 @@ /* globals describe */

describe('#compare()', () => {
it('should return the version in red and bold', () => {
it('should return the version in red and bold and the new version in green and bold', () => {
const result = packageAge.Versions.compare('1.2.0', '1.3.0');
assert.equal(result, chalk.bgRed.bold('1.2.0'));
assert.equal(result, `${chalk.bgRed.bold('1.2.0')} => ${chalk.bgGreen.bold('1.3.0')}`);
});

@@ -22,0 +22,0 @@ it('should return the version in green and bold', () => {

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