|
8 | 8 |
|
9 | 9 | - [Setup](#setup) |
10 | 10 | - [API](#api) |
11 | | - - [Gulp.create](#gulpcreate) |
12 | | - - [Gulp.createClass](#gulpcreateclass) |
13 | | - - [gulp.task](#gulptask) |
14 | | - - [gulp.start](#gulpstart) |
15 | | - - [gulp.series](#gulpseries) |
16 | | - - [gulp.parallel](#gulpparallel) |
17 | | - - [gulp.stack](#gulpstack) |
| 11 | + - [Gulp.create](#gulpcreate) |
| 12 | + - [Gulp.createClass](#gulpcreateclass) |
| 13 | + - [gulp.task](#gulptask) |
| 14 | + - [gulp.start](#gulpstart) |
| 15 | + - [gulp.series](#gulpseries) |
| 16 | + - [gulp.parallel](#gulpparallel) |
| 17 | + - [gulp.stack](#gulpstack) |
18 | 18 | - [CLI](#cli) |
19 | 19 | - [REPL](#repl) |
| 20 | +- [Task arguments](#task-arguments) |
20 | 21 | - [Customizable logging](#customizable-logging) |
21 | 22 |
|
22 | 23 | <h2>Introduction</h2> |
@@ -316,46 +317,87 @@ For more information see [gulp-repl][gulp-repl]. |
316 | 317 |
|
317 | 318 | Callbacks `onHandleStart`, `onHandleEnd` and `onHandleError` are used to produce logging. |
318 | 319 |
|
319 | | -These callbacks can be overridden at a class level with `Gulp.createClass`, add a instance level with `Gulp.create` or at a bunlde/run level with one of the composers (`gulp.start`, `gulp.series`, `gulp.parallel` and `gulp.stack`). |
| 320 | +These callbacks can be overridden at a class level with [`Gulp.createClass`](#gulpcreateclass), add a instance level with `Gulp.create` or at a bunlde/run level with one of the composers ([`gulp.start`](#gulpstart), [`gulp.series`](#gulpseries), [`gulp.parallel`](#gulpparallel) and [`gulp.stack`](#gulpstack)). |
320 | 321 |
|
321 | 322 | Example: |
322 | 323 |
|
323 | 324 | ```js |
324 | 325 | var MyGulp = require('gulp-runtime').createCLass({ |
325 | | - onHandleEnd: function (task) { |
326 | | - console.log('end', task.label); |
327 | | - }, |
| 326 | + onHandleEnd: function (task) { |
| 327 | + console.log('end', task.label); |
| 328 | + }, |
328 | 329 | onHandleStart: function (task) { |
329 | | - console.log('start', task.label); |
330 | | - }, |
331 | | - onHandleError: function (error, task, stack) { |
332 | | - console.log('error!', task.label); |
333 | | - throw error; |
334 | | - } |
| 330 | + console.log('start', task.label); |
| 331 | + }, |
| 332 | + onHandleError: function (error, task, stack) { |
| 333 | + console.log('error!', task.label); |
| 334 | + throw error; |
| 335 | + } |
335 | 336 | }); |
336 | 337 |
|
337 | 338 | var myGulp = MyGulp.create({ |
338 | | - onHandleStart: function (task) { |
339 | | - console.log(task.label, 'ended!'); |
340 | | - } |
| 339 | + onHandleStart: function (task) { |
| 340 | + console.log(task.label, 'ended!'); |
| 341 | + } |
341 | 342 | }); |
342 | 343 |
|
343 | 344 | myGulp.task(':name', function (done) { |
344 | | - if (this.params && this.params.name === 'three') { |
345 | | - throw new Error('ups, something broke'); |
346 | | - } else { |
347 | | - setTimeout(done, 1000); |
348 | | - } |
| 345 | + if (this.params && this.params.name === 'three') { |
| 346 | + throw new Error('ups, something broke'); |
| 347 | + } else { |
| 348 | + setTimeout(done, 1000); |
| 349 | + } |
349 | 350 | }); |
350 | 351 |
|
351 | | -gulp.stack('one', 'two', 'three', { |
352 | | - onHandleError: function (error, task, stack) { |
353 | | - console.log(task.label, 'is dead'); |
354 | | - console.log(error); |
355 | | - } |
| 352 | +myGulp.stack('one', 'two', 'three', { |
| 353 | + onHandleError: function (error, task, stack) { |
| 354 | + console.log(task.label, 'is dead'); |
| 355 | + console.log(error); |
| 356 | + } |
| 357 | +})(); |
| 358 | +``` |
| 359 | + |
| 360 | +## Task arguments |
| 361 | + |
| 362 | +Any of the task runners (([`gulp.start`](#gulpstart), [`gulp.series`](#gulpseries), [`gulp.parallel`](#gulpparallel) and [`gulp.stack`](#gulpstack))) can be used to pass arguments down. |
| 363 | + |
| 364 | +```js |
| 365 | +var gulp = require('gulp-runtime').create(); |
| 366 | +var args = [1, 2, 3]; |
| 367 | + |
| 368 | +gulp.task(':name', function (done, one, two, three) { |
| 369 | + console.log(one, two, three); |
| 370 | + done(null, one + two + three); |
| 371 | +}); |
| 372 | + |
| 373 | +// with gulp.stack |
| 374 | +gulp.stack('taskNameHere')(1, 2, 3, function (error, result) { |
| 375 | + if (error) { |
| 376 | + console.log('ups, who farted?'); |
| 377 | + console.log(error.stack); |
| 378 | + } else { |
| 379 | + console.log('all right, we are done at', result, 'pm today'); |
| 380 | + } |
356 | 381 | }); |
| 382 | + |
| 383 | +// with gulp.start |
| 384 | +gulp.task('default', function (done) { |
| 385 | + gulp.start(['taskNameHere'], 1, 2, 3, { |
| 386 | + onStackEnd: function () { |
| 387 | + if (error) { |
| 388 | + console.log('ups, who farted?'); |
| 389 | + console.log(error.stack); |
| 390 | + } else { |
| 391 | + console.log('all right, we are done at', result, 'pm today'); |
| 392 | + } |
| 393 | + done(); |
| 394 | + } |
| 395 | + }) |
| 396 | +}); |
| 397 | + |
357 | 398 | ``` |
358 | 399 |
|
| 400 | + |
359 | 401 | <!-- links --> |
360 | 402 |
|
361 | 403 | [npm]: https://npmjs.com/gulp-runtime |
|
0 commit comments