Commit 0cefa821 authored by nanahira's avatar nanahira

added try

parent 8e37b19f
...@@ -32,41 +32,55 @@ var sendResponse = function(text) { ...@@ -32,41 +32,55 @@ var sendResponse = function(text) {
var pull_data = function(path, remote, branch, callback) { var pull_data = function(path, remote, branch, callback) {
sendResponse("Started pulling on branch "+branch+" at "+path+" from "+remote+"."); sendResponse("Started pulling on branch "+branch+" at "+path+" from "+remote+".");
var proc = spawn("git", ["pull", remote, branch], { cwd: path, env: process.env }); try {
proc.stdout.setEncoding('utf8'); var proc = spawn("git", ["pull", remote, branch], { cwd: path, env: process.env });
proc.stdout.on('data', function(data) { proc.stdout.setEncoding('utf8');
sendResponse("git pull stdout: "+data); proc.stdout.on('data', function(data) {
}); sendResponse("git pull stdout: "+data);
proc.stderr.setEncoding('utf8'); });
proc.stderr.on('data', function(data) { proc.stderr.setEncoding('utf8');
sendResponse("git pull stderr: "+data); proc.stderr.on('data', function(data) {
}); sendResponse("git pull stderr: "+data);
proc.on('close', function (code) { });
sendResponse("Finished pulling on branch "+branch+" at "+path+" from "+remote+"."); proc.on('close', function (code) {
sendResponse("Finished pulling on branch "+branch+" at "+path+" from "+remote+".");
if (callback) {
callback();
}
});
catch (err) {
sendResponse("Errored pulling on branch "+branch+" at "+path+" from "+remote+".");
if (callback) { if (callback) {
callback(); callback();
} }
}); }
return proc; return;
} }
var run_custom_callback = function(command, args, path, callback) { var run_custom_callback = function(command, args, path, callback) {
sendResponse("Started running custom callback."); sendResponse("Started running custom callback.");
var proc = spawn(command, args, { cwd: path, env: process.env }); try {
proc.stdout.setEncoding('utf8'); var proc = spawn(command, args, { cwd: path, env: process.env });
proc.stdout.on('data', function(data) { proc.stdout.setEncoding('utf8');
sendResponse("custom callback stdout: "+data); proc.stdout.on('data', function(data) {
}); sendResponse("custom callback stdout: "+data);
proc.stderr.setEncoding('utf8'); });
proc.stderr.on('data', function(data) { proc.stderr.setEncoding('utf8');
sendResponse("custom callback stderr: "+data); proc.stderr.on('data', function(data) {
}); sendResponse("custom callback stderr: "+data);
proc.on('close', function (code) { });
sendResponse("Finished running custom callback."); proc.on('close', function (code) {
sendResponse("Finished running custom callback.");
if (callback) {
callback();
}
});
} catch (err) {
sendResponse("Errored running custom callback.");
if (callback) { if (callback) {
callback(); callback();
} }
}); }
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment