2014-12-02 21:21:07 +00:00
|
|
|
'use strict';
|
|
|
|
|
2014-12-03 21:24:00 +00:00
|
|
|
var ParentCommand = require('./spawn').Command,
|
2014-12-02 21:21:07 +00:00
|
|
|
inherits = require('util').inherits;
|
|
|
|
|
|
|
|
function Command(params) {
|
2014-12-03 22:23:41 +00:00
|
|
|
params = params || {};
|
2014-12-02 21:21:07 +00:00
|
|
|
ParentCommand.call(this, params);
|
2014-12-03 22:23:41 +00:00
|
|
|
this.shell = params.shell || '/bin/sh';
|
2014-12-02 21:21:07 +00:00
|
|
|
}
|
|
|
|
|
2014-12-03 22:23:41 +00:00
|
|
|
exports.Command = Command;
|
2014-12-02 21:21:07 +00:00
|
|
|
|
|
|
|
inherits(Command, ParentCommand);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2014-12-03 22:23:41 +00:00
|
|
|
* Executes `params.cmd` (e.g. 'echo 1 && echo 2') in a `shell`
|
|
|
|
* (which was set at constructor) with `params.options`
|
2014-12-02 21:21:07 +00:00
|
|
|
*/
|
|
|
|
Command.prototype.run = function(params, callback) {
|
2014-12-03 22:23:41 +00:00
|
|
|
ParentCommand.prototype.run.call(this, {
|
|
|
|
cmd: this.shell, args: ['-c', params.cmd], options: params.options
|
2014-12-02 21:21:07 +00:00
|
|
|
}, callback);
|
|
|
|
};
|