Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

count updates properly in the update message

  • Loading branch information...
commit e43c361994c25097a7afcea93df2f3238f86579a 1 parent f8a2712
@substack authored
Showing with 12 additions and 13 deletions.
  1. +4 −3 cli.js
  2. +5 −4 index.js
  3. +3 −6 package.json
View
7 cli.js
@@ -6,11 +6,12 @@ var print = require('util').print;
var cmd = process.argv[2] || '';
if (cmd === 'update') {
- console.log('Fetching packages...');
- npmdep.update(function (err, pkgs) {
+ console.log('Fetching metadata for new packages...');
+ npmdep.update(function (err, pkgs, updated) {
if (err) console.error(err.stack ? err.stack : err)
else console.log(
- 'Update OK. %d packages updated.',
+ 'Update OK. %d packages updated. %d packages total.',
+ Object.keys(updated).length,
Object.keys(pkgs).length
);
});
View
9 index.js
@@ -56,11 +56,11 @@ exports.tree = function (start, cb) {
};
exports.update = function (cb) {
- function after (err, pkgs) {
+ function after (err, pkgs, updated) {
if (err) cb(err)
else {
packages = pkgs;
- cb(null, pkgs);
+ cb(null, pkgs, updated);
}
}
@@ -108,10 +108,11 @@ function updateCache (cached, cb) {
}).bind(this), 250);
})
.seq(function () {
+ var updated = {};
Hash(newNames, this.stack).forEach(function (pkg, name) {
var nv = name.split('@');
var n = nv[0], v = nv[1];
- cached[n] = {
+ updated[n] = cached[n] = {
latest : v,
dependencies : pkg[name] && pkg[name].dependencies || {}
};
@@ -121,7 +122,7 @@ function updateCache (cached, cb) {
fs.writeFile(cacheFile, JSON.stringify(cached));
}
- cb(null, cached);
+ cb(null, cached, updated);
})
.catch(cb)
;
View
9 package.json
@@ -1,6 +1,6 @@
{
"name" : "npmdep",
- "version" : "0.0.1",
+ "version" : "0.0.2",
"description" : "Build a dependency graph for npm packages",
"repository" : {
"type" : "git",
@@ -9,9 +9,7 @@
"bin" : {
"npmdep" : "./cli.js"
},
- "modules" : {
- "index" : "./index.js"
- },
+ "main" : "./index.js",
"dependencies" : {
"traverse" : ">=0.2.3",
"seq" : ">=0.1.7",
@@ -22,8 +20,7 @@
"npm",
"dependencies",
"graph",
- "contributors",
- "npm"
+ "contributors"
],
"author" : {
"name" : "James Halliday",
Please sign in to comment.
Something went wrong with that request. Please try again.