build(gulp): run beforeExit hook only once

this prevents inifinite loops when cleanup task registers an additional task, that triggers a new beforeExit event

Fixes #1833
This commit is contained in:
Igor Minar 2015-05-12 21:19:59 -07:00
parent af9dcad8e3
commit 718d2ae2ee
1 changed files with 5 additions and 0 deletions

View File

@ -832,6 +832,11 @@ process.on('SIGINT', function() {
}); });
// register cleanup listener for all non-persistent tasks // register cleanup listener for all non-persistent tasks
var beforeExitRan = false;
process.on('beforeExit', function() { process.on('beforeExit', function() {
if (beforeExitRan) return;
beforeExitRan = true;
gulp.start('cleanup.builder'); gulp.start('cleanup.builder');
}); });