Permalink
Browse files
[feature] add shell option
- Loading branch information...
Showing
with
14 additions
and
2 deletions.
-
+5
−1
execspawn.js
-
+9
−1
test.js
|
|
@@ -7,7 +7,7 @@ module.exports = function execstream(command, options) { |
|
|
options = extend({}, options);
|
|
|
|
|
|
if (process.platform === 'win32') {
|
|
|
file = 'cmd.exe';
|
|
|
file = process.env.comspec || 'cmd.exe';
|
|
|
args = ['/s', '/c', '"' + command + '"'];
|
|
|
options.windowsVerbatimArguments = true;
|
|
|
} else {
|
|
|
@@ -16,5 +16,9 @@ module.exports = function execstream(command, options) { |
|
|
options.windowsVerbatimArguments = false;
|
|
|
}
|
|
|
|
|
|
if (options && options.shell) {
|
|
|
file = options.shell;
|
|
|
}
|
|
|
|
|
|
return spawn(file, args, options);
|
|
|
};
|
|
|
@@ -3,10 +3,18 @@ var test = require('tap').test; |
|
|
var execstream = require('./execspawn.js');
|
|
|
var endpoint = require('endpoint');
|
|
|
|
|
|
test('simple test', function (t) {
|
|
|
test('default', function (t) {
|
|
|
execstream('echo "hallo world";').stdout.pipe(endpoint(function (err, out) {
|
|
|
t.equal(err, null);
|
|
|
t.equal(out.toString(), 'hallo world\n');
|
|
|
t.end();
|
|
|
}));
|
|
|
});
|
|
|
|
|
|
test('shell option', function (t) {
|
|
|
execstream('hallo world', { shell: 'echo' }).stdout.pipe(endpoint(function (err, out) {
|
|
|
t.equal(err, null);
|
|
|
t.equal(out.toString(), '-c hallo world\n');
|
|
|
t.end();
|
|
|
}));
|
|
|
});
|
0 comments on commit
b2bd67a