Skip to content

Commit ad0d7e0

Browse files
committed
Add options.shell
1 parent 5077199 commit ad0d7e0

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ You can override any environment variables with this option.
9191

9292
For example, setting it to `{PATH: process.env.PATH}` will reset the `PATH` if the default one brings your some troubles.
9393

94+
#### options.shell
95+
96+
type: `String`
97+
98+
default: `/bin/sh` on UNIX, and `cmd.exe` on Windows
99+
100+
Change it to `bash` if you like.
101+
94102
#### options.quiet
95103

96104
type: `Boolean`

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function normalizeCommands (commands) {
2222
function normalizeOptions (options) {
2323
options = _.extend({
2424
cwd: process.cwd(),
25+
shell: true,
2526
quiet: false,
2627
verbose: false,
2728
ignoreErrors: false,
@@ -48,7 +49,7 @@ function runCommands (commands, options, file, done) {
4849
var child = spawn(command, {
4950
env: options.env,
5051
cwd: gutil.template(options.cwd, context),
51-
shell: true,
52+
shell: options.shell,
5253
stdio: options.quiet ? 'ignore' : 'inherit'
5354
})
5455

test/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('gulp-shell(commands, options)', function () {
5151
it('prepends `./node_modules/.bin` to `PATH`', function (done) {
5252
var stream = shell([
5353
'echo $PATH | grep -q "' + join(process.cwd(), 'node_modules/.bin') + '"'
54-
])
54+
], {shell: 'bash'})
5555

5656
expectToBeOk(stream, done)
5757

@@ -91,6 +91,18 @@ describe('gulp-shell(commands, options)', function () {
9191
})
9292
})
9393

94+
describe('shell', function () {
95+
it('changes the shell', function (done) {
96+
var stream = shell([
97+
'[[ $0 = bash ]]'
98+
], {shell: 'bash'})
99+
100+
expectToBeOk(stream, done)
101+
102+
stream.write(fakeFile)
103+
})
104+
})
105+
94106
describe('quiet', function () {
95107
it("won't output anything when `quiet` == true", function (done) {
96108
var stream = shell(['echo cannot see me!'], {quiet: true})

0 commit comments

Comments
 (0)