Skip to content

Commit 5077199

Browse files
committed
Rearrange options
1 parent 015d75e commit 5077199

File tree

3 files changed

+61
-63
lines changed

3 files changed

+61
-63
lines changed

README.md

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,64 +73,62 @@ type: `Array` or `String`
7373

7474
A command can be a [template][] which can be interpolated by some [file][] info (e.g. `file.path`).
7575

76-
[template]: http://lodash.com/docs#template
77-
[file]: https://github.com/wearefractal/vinyl
76+
#### options.cwd
7877

79-
#### options.verbose
78+
type: `String`
8079

81-
type: `Boolean`
80+
default: [`process.cwd()`](http://nodejs.org/api/process.html#process_process_cwd)
8281

83-
default: `false`
82+
Sets the current working directory for the command. This can be a [template][] which can be interpolated by some [file][] info (e.g. `file.path`).
8483

85-
Set to `true` to print the command(s) to stdout as they are executed
84+
#### options.env
8685

87-
#### options.errorMessage
86+
type: `Object`
8887

89-
type: `String`
88+
By default, all the commands will be executed in an environment with all the variables in [`process.env`](http://nodejs.org/api/process.html#process_process_env) and `PATH` prepended by `./node_modules/.bin` (allowing you to run executables in your Node's dependencies).
9089

91-
default: ``Command `<%= command %>` failed with exit code <%= error.code %>``
90+
You can override any environment variables with this option.
9291

93-
You can add a custom error message for when the command fails.
94-
This can be a [template][] which can be interpolated with the current `command`, some [file][] info (e.g. `file.path`) and some error info (e.g. `error.code`).
92+
For example, setting it to `{PATH: process.env.PATH}` will reset the `PATH` if the default one brings your some troubles.
9593

96-
#### options.ignoreErrors
94+
#### options.quiet
9795

9896
type: `Boolean`
9997

10098
default: `false`
10199

102-
By default, it will emit an `error` event when the command finishes unsuccessfully.
100+
By default, it will print the command output.
103101

104-
#### options.quiet
102+
#### options.verbose
105103

106104
type: `Boolean`
107105

108106
default: `false`
109107

110-
By default, it will print the command output.
108+
Set to `true` to print the command(s) to stdout as they are executed
111109

112-
#### options.cwd
110+
#### options.ignoreErrors
113111

114-
type: `String`
112+
type: `Boolean`
115113

116-
default: [`process.cwd()`](http://nodejs.org/api/process.html#process_process_cwd)
114+
default: `false`
117115

118-
Sets the current working directory for the command. This can be a [template][] which can be interpolated by some [file][] info (e.g. `file.path`).
116+
By default, it will emit an `error` event when the command finishes unsuccessfully.
119117

120-
[template]: http://lodash.com/docs#template
118+
#### options.errorMessage
121119

122-
#### options.templateData
120+
type: `String`
123121

124-
type: `Object`
122+
default: ``Command `<%= command %>` failed with exit code <%= error.code %>``
125123

126-
The data that can be accessed in template.
124+
You can add a custom error message for when the command fails.
125+
This can be a [template][] which can be interpolated with the current `command`, some [file][] info (e.g. `file.path`) and some error info (e.g. `error.code`).
127126

128-
#### options.env
127+
#### options.templateData
129128

130129
type: `Object`
131130

132-
By default, all the commands will be executed in an environment with all the variables in [`process.env`](http://nodejs.org/api/process.html#process_process_env) and `PATH` prepended by `./node_modules/.bin` (allowing you to run executables in your Node's dependencies).
133-
134-
You can override any environment variables with this option.
131+
The data that can be accessed in [template][].
135132

136-
For example, setting it to `{PATH: process.env.PATH}` will reset the `PATH` if the default one brings your some troubles.
133+
[template]: http://lodash.com/docs#template
134+
[file]: https://github.com/wearefractal/vinyl

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ function normalizeCommands (commands) {
2121

2222
function normalizeOptions (options) {
2323
options = _.extend({
24+
cwd: process.cwd(),
25+
quiet: false,
2426
verbose: false,
2527
ignoreErrors: false,
26-
errorMessage: 'Command `<%= command %>` failed with exit code <%= error.code %>',
27-
quiet: false,
28-
cwd: process.cwd()
28+
errorMessage: 'Command `<%= command %>` failed with exit code <%= error.code %>'
2929
}, options)
3030

3131
var pathToBin = path.join(process.cwd(), 'node_modules', '.bin')

test/index.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,38 @@ describe('gulp-shell(commands, options)', function () {
6969
})
7070

7171
describe('options', function () {
72+
describe('cwd', function () {
73+
it('sets the current working directory when `cwd` is a string', function (done) {
74+
var stream = shell([
75+
'test $PWD = ' + join(__dirname, '../..')
76+
], {cwd: '..'})
77+
78+
expectToBeOk(stream, done)
79+
80+
stream.write(fakeFile)
81+
})
82+
83+
it('uses the process current working directory when `cwd` is not passed', function (done) {
84+
var stream = shell([
85+
'test $PWD = ' + join(__dirname, '..')
86+
])
87+
88+
expectToBeOk(stream, done)
89+
90+
stream.write(fakeFile)
91+
})
92+
})
93+
94+
describe('quiet', function () {
95+
it("won't output anything when `quiet` == true", function (done) {
96+
var stream = shell(['echo cannot see me!'], {quiet: true})
97+
98+
expectToBeOk(stream, done)
99+
100+
stream.write(fakeFile)
101+
})
102+
})
103+
72104
describe('ignoreErrors', function () {
73105
it('emits error by default', function (done) {
74106
var stream = shell(['false'])
@@ -95,16 +127,6 @@ describe('gulp-shell(commands, options)', function () {
95127
})
96128
})
97129

98-
describe('quiet', function () {
99-
it("won't output anything when `quiet` == true", function (done) {
100-
var stream = shell(['echo cannot see me!'], {quiet: true})
101-
102-
expectToBeOk(stream, done)
103-
104-
stream.write(fakeFile)
105-
})
106-
})
107-
108130
describe('errorMessage', function () {
109131
it('allows for custom messages', function (done) {
110132
var errorMessage = 'foo'
@@ -131,27 +153,5 @@ describe('gulp-shell(commands, options)', function () {
131153
stream.write(fakeFile)
132154
})
133155
})
134-
135-
describe('cwd', function () {
136-
it('sets the current working directory when `cwd` is a string', function (done) {
137-
var stream = shell([
138-
'test $PWD = ' + join(__dirname, '../..')
139-
], {cwd: '..'})
140-
141-
expectToBeOk(stream, done)
142-
143-
stream.write(fakeFile)
144-
})
145-
146-
it('uses the process current working directory when `cwd` is not passed', function (done) {
147-
var stream = shell([
148-
'test $PWD = ' + join(__dirname, '..')
149-
])
150-
151-
expectToBeOk(stream, done)
152-
153-
stream.write(fakeFile)
154-
})
155-
})
156156
})
157157
})

0 commit comments

Comments
 (0)