Skip to content
Browse files

Add calls to process.nextTick

This makes code not run until the next event loop, which is good for call back stuff.
  • Loading branch information...
1 parent f7f78c9 commit 28b2225483e361ce16d7579c17b0000fb23d8c82 @mythmon committed Apr 3, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 ears.js
View
12 ears.js
@@ -41,12 +41,16 @@ function handleHit(data, callback) {
var repo = data.repository.name;
options = config.repositories[repo];
if (options === undefined) {
- callback('no such repository "' + repo + '"');
+ process.nextTick(function() {
+ callback('no such repository "' + repo + '"');
+ });
return;
}
cp.exec('git pull', {cwd: options.path}, function (error, stdout, stderr) {
if (error) {
- callback(stderr);
+ process.nextTick(function() {
+ callback(stderr);
+ });
} else {
scriptPath = options.script;
if (options.script !== undefined) {
@@ -59,7 +63,9 @@ function handleHit(data, callback) {
}
});
} else {
- callback();
+ process.nextTick(function() {
+ callback();
+ });
}
}
});

0 comments on commit 28b2225

Please sign in to comment.
Something went wrong with that request. Please try again.