package-age
Advanced tools
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', () => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
234049
206
+ Addedread-pkg@4.0.1(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedload-json-file@4.0.0(transitive)
- Removedpath-type@3.0.0(transitive)
- Removedread-pkg@3.0.0(transitive)
- Removedstrip-bom@3.0.0(transitive)
Updatedcommander@^2.16.0
Updatedread-pkg@^4.0.1