Permalink
Browse files

Adds sshOptions array to hosts objects and changes process variable n…

…ame to avoid confusion with node process global.
  • Loading branch information...
1 parent b9753c4 commit e1ca0b91e753fa51e967a4ac5bf1aad4dd3775b9 Tom Smith committed Aug 8, 2010
Showing with 19 additions and 11 deletions.
  1. +19 −11 lib/host.js
View
@@ -9,17 +9,17 @@ function logBuffer(log, prefix, buffer) {
log.puts(message, prefix);
}
-function listen(process, log, callback) {
+function listen(subProcess, log, callback) {
var codes = '';
- process.stdout.addListener('data', function (data) {
+ subProcess.stdout.addListener('data', function (data) {
logBuffer(log, 'stdout: ', data);
});
- process.stderr.addListener('data', function (data) {
+ subProcess.stderr.addListener('data', function (data) {
logBuffer(log, 'stderr: ', data);
});
- process.addListener('exit', function (code) {
+ subProcess.addListener('exit', function (code) {
logBuffer(log, 'exit: ', code);
if (code === 0 && callback) {
callback(this);
@@ -34,11 +34,19 @@ function ssh(command, callback) {
var log = this.logger,
user = this.user,
- process = spawn('ssh',
- ['-l' + user, this.address, "''" + command + "''"]);
+ options = this.sshOptions,
+ args = ['-l' + user, this.address, "''" + command + "''"],
+ subProcess;
+
+ if (options) {
+ args = options.concat(args);
+ }
+
+ subProcess = spawn('ssh', args);
+ console.log('args' + args);
log.puts(user + ':ssh ' + command);
- listen(process, log, callback);
+ listen(subProcess, log, callback);
}
function scp(local, remote, callback) {
@@ -56,11 +64,11 @@ function scp(local, remote, callback) {
path.exists(local, function (exists) {
if (exists) {
var reference = user + '@' + address + ':' + remote,
- args = [local, reference],
- process = spawn('scp', args);
+ args = ['-r', local, reference],
+ subProcess = spawn('scp', args);
log.puts(user + ':scp: ' + local + ' ' + reference);
- listen(process, log, callback);
+ listen(subProcess, log, callback);
} else {
throw new Error('Local: ' + local + ' does not exist');
}
@@ -84,6 +92,7 @@ function hostConstructor(config) {
this.address = address;
this.logger = new Log(this.address + ':', logPath, true);
this.log = log;
+ this.sshOptions = [];
this.ssh = ssh;
this.scp = scp;
@@ -109,7 +118,6 @@ function host(config, address) {
return new Host(address);
}
-
function hosts(config, addresses) {
if (!config) {
throw new Error("No config");

0 comments on commit e1ca0b9

Please sign in to comment.