Permalink
Browse files

[feature] add shell option

  • Loading branch information...
AndreasMadsen committed Jan 5, 2016
1 parent ffc9b65 commit b2bd67ae4dc95a95ee589227704c4cac680097d6
Showing with 14 additions and 2 deletions.
  1. +5 −1 execspawn.js
  2. +9 −1 test.js
View
@@ -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);
};
View
10 test.js
@@ -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

Please sign in to comment.