You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -88,7 +88,7 @@ The gulp community is growing, with new plugins being added daily. See the [npm
88
88
89
89
### gulp.src(globs[, options])
90
90
91
-
Takes a glob and represents a file structure. Can be piped to plugins. You can specify a single glob or an array of globs (see docs). All options are passed directly through to [glob-stream]. See the [glob-stream documentation] for more information.
91
+
Takes a glob and represents a file structure. Can be piped to plugins.
Options to pass to [node-glob] through [glob-stream].
109
+
110
+
gulp adds two additional options in addition to the [options supported by node-glob][node-glob documentation]:
111
+
100
112
#### options.buffer
101
113
Type: `Boolean`
102
114
Default: `true`
103
115
104
-
Setting this to `false` will return `file.contents` as a stream and not buffer files. This may not be supported by many plugins.
116
+
Setting this to `false` will return `file.contents` as a stream and not buffer files. This is useful when working with large files. **Note:** Plugins may not implement support for streams.
105
117
106
118
#### options.read
107
119
Type: `Boolean`
108
120
Default: `true`
109
121
110
122
Setting this to `false` will return `file.contents` as null and not read the file at all.
111
123
112
-
### gulp.dest(path[, options])
124
+
125
+
### gulp.dest(path)
113
126
114
127
Can be piped to and it will write files. Re-emits all data passed to it so you can pipe to multiple folders.
If the dependencies are asynchronous it is not guaranteed that they will finish before `'somename'` is executed. To ensure they are completely finished, you need to make sure the dependency tasks have asynchronous support through one of the methods outlined below. The most simple method is to return the stream. By returning the stream, Orchestrator is able to listen for the end event and only run `'somename'` once each dependencies' stream end event has been emitted. You can also use callbacks or promises to do your own cool stuff.
168
+
**Note:** If the dependencies are asynchronous it is not guaranteed that they will finish before `mytask` is executed. To ensure they are completely finished, you need to make sure the dependency tasks have asynchronous support through one of the methods outlined below.
169
+
170
+
#### fn
171
+
172
+
The function that performs the task's operations. Generally this takes the form of `gulp.src().pipe(someplugin())`.
147
173
148
-
#### Async tasks
174
+
#### Async task support
149
175
150
-
With callbacks:
176
+
Tasks can be made asynchronous if its `fn` does one of the following:
Triggers tasks to be executed. *Does not run in order*.
217
+
#### tasks
218
+
Type: `String`
219
+
220
+
Tasks to be executed. You may pass any number of tasks as individual arguments. **Note:** Tasks are run concurrently and therefore do not run in order, see [Orchestrator] for more information.
Use gulp.run to run tasks from other tasks. You will probably use this in your default task and to group small tasks into larger tasks.
232
+
Use `gulp.run` to run tasks from other tasks. You will probably use this in your default task and to group small tasks into larger tasks.
202
233
203
234
### gulp.watch(glob, cb)
204
235
205
-
glob can be a standard glob or an array of globs. cb is called on each fs change with an object describing the change.
236
+
#### glob
237
+
Type: `String` or `Array`
238
+
239
+
A single glob or array of globs that indicate which files to watch for changes.
240
+
241
+
#### cb(event)
242
+
Type: `Function`
243
+
244
+
Callback to be called on each change.
206
245
207
246
```javascript
208
247
gulp.watch('js/**/*.js', function(event) {
248
+
console.log('File '+event.path+' was '+event.type+', running tasks...');
209
249
gulp.run('scripts', 'copyfiles');
210
250
});
211
251
```
212
252
253
+
The callback will be passed an object, `event`, that describes the change:
254
+
255
+
##### event.type
256
+
Type: `String`
257
+
258
+
The type of change that occurred, either `added`, `changed` or `deleted`.
259
+
260
+
##### event.path
261
+
Type: `String`
262
+
263
+
The path to the file that triggered the event.
264
+
265
+
213
266
### gulp.env
214
267
215
-
gulp.env is an optimist arguments object. Running `gulp test dostuff --production` will yield `{_:["test","dostuff"],production:true}`. Plugins don't use this.
268
+
`gulp.env` is a [node-optimist] arguments object. For instance, if you run:
269
+
270
+
```
271
+
gulp test dostuff --production
272
+
```
273
+
274
+
Which results in the following `gulp.env`:
275
+
276
+
```
277
+
{
278
+
_: ['test', 'dostuff'],
279
+
production:true
280
+
}
281
+
```
282
+
283
+
You can use this to conditionally enable certain plugins:
284
+
285
+
```
286
+
gulp.task('scripts', function() {
287
+
var stream =gulp.src(['client/js/**/*.js', '!client/js/vendor/**']);
288
+
289
+
// Only uglify in production
290
+
if (!gulp.env.production) {
291
+
stream =stream.pipe(uglify());
292
+
}
293
+
294
+
stream.pipe(gulp.dest('build/js'));
295
+
});
296
+
```
297
+
298
+
**Note:** Plugins should not perform differently based on `gulp.env`.
216
299
217
300
218
301
## gulp CLI
@@ -223,7 +306,7 @@ Tasks can be executed by running `gulp <task> <othertask>`. Just running `gulp`
223
306
224
307
### Compilers
225
308
226
-
You can use any language you want for your gulpfile. You will have to specify the language module name so the CLI can load it (and its assosciated extensions) before attempting to find your gulpfile. Make sure you have this module installed accessible by the folder you are running the CLI in.
309
+
You can use any language you want for your gulpfile. You will have to specify the language module name so the CLI can load it (and its associated extensions) before attempting to find your gulpfile. Make sure you have this module installed accessible by the folder you are running the CLI in.
227
310
228
311
Example:
229
312
@@ -271,7 +354,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0 commit comments