Skip to content

Commit

Permalink
add advanced options to Transport#exec()
Browse files Browse the repository at this point in the history
  • Loading branch information
pstadler committed Dec 13, 2014
1 parent 1f1c6ee commit e07edc7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,19 @@ var result = transport.echo('Hello world');
console.log(result); // { code: 0, stdout: 'Hello world\n', stderr: null }
```

#### Advanced options
Flightplan uses `child_process#exec()` for executing local commands and
`mscdex/ssh2#exec()` for remote commands. Options passed with `exec` will
be forwarded to either of these functions.

```javascript
// increase maxBuffer for child_process#exec()
local.ls('-al', {exec: {maxBuffer: 2000*1024}});

// enable pty for mscdex/ssh2#exec()
remote.ls('-al', {exec: {pty: true}});
```

### <a name="transport.sudo(command%5B%2C%20options%5D)"></a>transport.sudo(command[, options]) → code: int, stdout: String, stderr: String

Execute a command as another user with `sudo()`. It has the same
Expand Down
13 changes: 13 additions & 0 deletions lib/transport/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ Transport.prototype._exec = function() {
* console.log(result); // { code: 0, stdout: 'Hello world\n', stderr: null }
* ```
*
* #### Advanced options
* Flightplan uses `child_process#exec()` for executing local commands and
* `mscdex/ssh2#exec()` for remote commands. Options passed with `exec` will
* be forwarded to either of these functions.
*
* ```javascript
* // increase maxBuffer for child_process#exec()
* local.ls('-al', {exec: {maxBuffer: 2000*1024}});
*
* // enable pty for mscdex/ssh2#exec()
* remote.ls('-al', {exec: {pty: true}});
* ```
*
* @method exec(command[, options])
* @return code: int, stdout: String, stderr: String
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/transport/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Shell.prototype._exec = function(command, options) {
self._logger.command(command);

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

proc.stdout.on('data', function(data) {
result.stdout = (result.stdout || '') + data;
Expand Down
2 changes: 1 addition & 1 deletion lib/transport/ssh.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ SSH.prototype._exec = function(command, options) {

var fiber = Fiber.current;

self._connection.exec(command, function(err, stream) {
self._connection.exec(command, options.exec || {}, function(err, stream) {

stream.on('data', function(data) {
result.stdout = (result.stdout || '') + data;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "flightplan",
"description": "Library for streamlining application deployment or systems administration tasks",
"version": "0.5.4",
"version": "0.5.5",
"author": "Patrick Stadler <patrick.stadler@gmail.com>",
"keywords": [
"deploy",
Expand Down

0 comments on commit e07edc7

Please sign in to comment.