Skip to content

Commit e07edc7

Browse files
committed
add advanced options to Transport#exec()
1 parent 1f1c6ee commit e07edc7

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,19 @@ var result = transport.echo('Hello world');
377377
console.log(result); // { code: 0, stdout: 'Hello world\n', stderr: null }
378378
```
379379

380+
#### Advanced options
381+
Flightplan uses `child_process#exec()` for executing local commands and
382+
`mscdex/ssh2#exec()` for remote commands. Options passed with `exec` will
383+
be forwarded to either of these functions.
384+
385+
```javascript
386+
// increase maxBuffer for child_process#exec()
387+
local.ls('-al', {exec: {maxBuffer: 2000*1024}});
388+
389+
// enable pty for mscdex/ssh2#exec()
390+
remote.ls('-al', {exec: {pty: true}});
391+
```
392+
380393
### <a name="transport.sudo(command%5B%2C%20options%5D)"></a>transport.sudo(command[, options]) → code: int, stdout: String, stderr: String
381394

382395
Execute a command as another user with `sudo()`. It has the same

lib/transport/index.js

+13
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ Transport.prototype._exec = function() {
117117
* console.log(result); // { code: 0, stdout: 'Hello world\n', stderr: null }
118118
* ```
119119
*
120+
* #### Advanced options
121+
* Flightplan uses `child_process#exec()` for executing local commands and
122+
* `mscdex/ssh2#exec()` for remote commands. Options passed with `exec` will
123+
* be forwarded to either of these functions.
124+
*
125+
* ```javascript
126+
* // increase maxBuffer for child_process#exec()
127+
* local.ls('-al', {exec: {maxBuffer: 2000*1024}});
128+
*
129+
* // enable pty for mscdex/ssh2#exec()
130+
* remote.ls('-al', {exec: {pty: true}});
131+
* ```
132+
*
120133
* @method exec(command[, options])
121134
* @return code: int, stdout: String, stderr: String
122135
*/

lib/transport/shell.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Shell.prototype._exec = function(command, options) {
3030
self._logger.command(command);
3131

3232
var fiber = Fiber.current;
33-
var proc = exec(command, { maxBuffer: 1000*1024 });
33+
var proc = exec(command, extend({ maxBuffer: 1000*1024 }, options.exec));
3434

3535
proc.stdout.on('data', function(data) {
3636
result.stdout = (result.stdout || '') + data;

lib/transport/ssh.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ SSH.prototype._exec = function(command, options) {
5252

5353
var fiber = Fiber.current;
5454

55-
self._connection.exec(command, function(err, stream) {
55+
self._connection.exec(command, options.exec || {}, function(err, stream) {
5656

5757
stream.on('data', function(data) {
5858
result.stdout = (result.stdout || '') + data;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "flightplan",
33
"description": "Library for streamlining application deployment or systems administration tasks",
4-
"version": "0.5.4",
4+
"version": "0.5.5",
55
"author": "Patrick Stadler <[email protected]>",
66
"keywords": [
77
"deploy",

0 commit comments

Comments
 (0)