Skip to content
Browse files

Initializes scpOptions as array if not configured so later logic can …

…assume array.
  • Loading branch information...
1 parent f6e818a commit e48ee0cecb64afa2d160a48f13fddcc61e69af53 @tsmith committed Jun 11, 2011
Showing with 15 additions and 9 deletions.
  1. +3 −0 CHANGELOG
  2. +5 −5 README
  3. +4 −1 example/mycontroller.js
  4. +3 −3 lib/host.js
View
3 CHANGELOG
@@ -1,3 +1,6 @@
+0.1.9
+- Init scpOptions as array if not configured so later logic can assume array
+
0.1.8
- Add exit callbacks to host.ssh(), host.scp() for handling non-zero exit codes
- Add scpOptions (like sshOptions)
View
10 README
@@ -398,8 +398,8 @@ In your ssh config file (create if it does not exist):
To pass options to the ssh command when using ssh(), add the option or options
-as an array to the sshOptions property of the config, or concat the option or
-options to the host object sshOptions property prior to executing the command:
+as an array to the sshOptions property of the config, or modify the sshOptions
+property of the host on the fly:
// Config task
config = {
@@ -408,11 +408,10 @@ options to the host object sshOptions property prior to executing the command:
};
// Work task
- host.sshOptions = host.sshOptions.concat('-v');
+ host.sshOptions.push('-v');
-Use scpOptions in the same manner to pass options to the scp command when using
-scp().
+Use scpOptions in the same manner for scp().
@@ -460,6 +459,7 @@ but is available if config tasks need to have command line arguments or rewrite
the work task name and its arguments on the fly.
+
FEEDBACK
Welcome at node@thomassmith.com or the Node mailing list.
View
5 example/mycontroller.js
@@ -55,7 +55,10 @@ task('arbexit', 'Arbitrary exit', function (host, code) {
});
task('scp', 'Test scp options', function (host) {
- host.scp(script, scpTest);
+ var flag = host.scpOptions.pop();
+ host.scp(script, scpTest); // Quietly
+ host.scpOptions.push(flag);
+ host.scp(script, scpTest); // Verbosely
});
task('clean', 'Remove file transferred in scp testing', function (host) {
View
6 lib/host.js
@@ -110,10 +110,10 @@ var defaultLogPath = 'hosts.log';
function hostConstructor(config) {
- // Initialize the sshOptions array here if not initialized in user-defined
- // config task instead of inside constructor so that the host object
- // sshOptions property points to a initially shared array in either case.
+ // Initialize ssh and scp options to an array if not specified so later
+ // logic can assume an array exists when adding or removing options.
config.sshOptions = config.sshOptions || [];
+ config.scpOptions = config.scpOptions || [];
// This function may get called with different config objects
// during a single config task (see roles example in README). Therefore

0 comments on commit e48ee0c

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