Skip to content

Commit edb825a

Browse files
committed
[ci skip] docs: pass arguments
1 parent b6a861a commit edb825a

File tree

1 file changed

+72
-30
lines changed

1 file changed

+72
-30
lines changed

docs/README.md

Lines changed: 72 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88

99
- [Setup](#setup)
1010
- [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)
1818
- [CLI](#cli)
1919
- [REPL](#repl)
20+
- [Task arguments](#task-arguments)
2021
- [Customizable logging](#customizable-logging)
2122

2223
<h2>Introduction</h2>
@@ -316,46 +317,87 @@ For more information see [gulp-repl][gulp-repl].
316317

317318
Callbacks `onHandleStart`, `onHandleEnd` and `onHandleError` are used to produce logging.
318319

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)).
320321

321322
Example:
322323

323324
```js
324325
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+
},
328329
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+
}
335336
});
336337

337338
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+
}
341342
});
342343

343344
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+
}
349350
});
350351

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+
}
356381
});
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+
357398
```
358399

400+
359401
<!-- links -->
360402

361403
[npm]: https://npmjs.com/gulp-runtime

0 commit comments

Comments
 (0)