added pull request extra

pull/272/head
Shannon Duncan 2016-02-17 22:39:49 +00:00 zatwierdzone przez nightwing
rodzic 4b34d6aa19
commit c6d501dd56
1 zmienionych plików z 26 dodań i 9 usunięć

Wyświetl plik

@ -139,17 +139,34 @@ define(function(require, exports, module) {
} }
function openWithPipe(callback) { function openWithPipe(callback) {
bridge.send({ type: "pipe" }, function(err, response) { bridge.send({ type: "pipe" }, function cb(err, response) {
if (err) { if (err) {
console.log(err.message); if (err.code == "ECONNREFUSED") {
return; // Seems Cloud9 is not running, lets start it up
startCloud9Local({}, function(success) {
if (success)
bridge.send({ type: "pipe" }, cb);
else {
console.log("Could not start Cloud9. "
+ "Please check your configuration.");
callback(err);
process.exit(40); // This appears to be needed; let's return something useful
}
});
return;
}
else {
console.log(err.message);
return;
}
} }
var stdin = process.openStdin(); var stdin = process.openStdin();
var finished = false; var finished = 0;
stdin.on("data", function(chunk) { stdin.on("data", function(chunk) {
finished = false; finished++;
bridge.send({ bridge.send( {
type: "pipeData", type: "pipeData",
data: decoder.write(chunk), data: decoder.write(chunk),
tab: response tab: response
@ -158,13 +175,13 @@ define(function(require, exports, module) {
// Escaping that error so end users aren't confused... // Escaping that error so end users aren't confused...
if (err && err.message !== "No Response") if (err && err.message !== "No Response")
console.log(err.message); console.log(err.message);
finished = true; finished--;
}); });
}); });
stdin.on("end", function() { stdin.on("end", function() {
(function retry() { (function retry() {
if(finished) if(finished === 0)
process.exit(40); process.exit();
setTimeout(retry, 100); setTimeout(retry, 100);
})(); })();
}); });