Add package event that is fired for each installed/uninstalled package.

This commit is contained in:
André Cruz
2012-12-14 14:57:58 +00:00
parent 5f094a894a
commit 7337a80550
3 changed files with 12 additions and 3 deletions

View File

@@ -144,7 +144,10 @@ module.exports = function (names, options) {
var uninstall = function () {
async.forEach(uninstallables, function (pkg, next) {
pkg.on('uninstall', next).uninstall();
pkg.on('uninstall', function () {
emitter.emit('package', pkg);
next();
}).uninstall();
}, function () {
// Finally save
if (options.save) save();

View File

@@ -6,7 +6,8 @@
// http://opensource.org/licenses/MIT
// ==========================================
// Events:
// - install: fired when package installed
// - install: fired when everything is installed
// - package: fired for each installed packaged
// - resolve: fired when deps resolved (with a true/false indicating success or error)
// - error: fired on all errors
// - data: fired when trying to output data
@@ -191,7 +192,10 @@ Manager.prototype.prune = function () {
Manager.prototype.install = function () {
async.forEach(Object.keys(this.dependencies), function (name, next) {
var pkg = this.dependencies[name][0];
pkg.once('install', next).install();
pkg.once('install', function () {
this.emit('package', pkg);
next();
}.bind(this)).install();
pkg.once('error', next);
}.bind(this), function () {
if (this.errors.length) this.reportErrors();