Skip to content

Commit 8aa1022

Browse files
SyntaxRulesphated
authored andcommitted
Docs: Add gulp.tree API & examples
1 parent 409f19a commit 8aa1022

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed

docs/API.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,154 @@ Type: String
535535

536536
The path to the file that triggered the event.
537537

538+
### gulp.tree(options)
539+
540+
Returns the tree of tasks. Inherited from [undertaker]. See the [undertaker docs for this function](https://github.com/phated/undertaker#treeoptions--object).
541+
542+
#### options
543+
Type: Object
544+
545+
Options to pass to [undertaker].
546+
547+
##### options.deep
548+
Type: `Boolean`
549+
550+
Default: `false`
551+
552+
If set to true whole tree should be returned.
553+
554+
#### Example gulpfile
555+
556+
```js
557+
gulp.task('one', function(done) {
558+
// do stuff
559+
done();
560+
});
561+
562+
gulp.task('two', function(done) {
563+
// do stuff
564+
done();
565+
});
566+
567+
gulp.task('three', function(done) {
568+
// do stuff
569+
done();
570+
});
571+
572+
gulp.task('four', gulp.series('one', 'two'));
573+
574+
gulp.task('five',
575+
gulp.series('four',
576+
gulp.parallel('three', function(done) {
577+
// do more stuff
578+
done();
579+
})
580+
)
581+
);
582+
```
583+
584+
#### Example tree output
585+
586+
```js
587+
gulp.tree()
588+
589+
// output: [ 'one', 'two', 'three', 'four', 'five' ]
590+
591+
gulp.tree({ deep: true })
592+
593+
/*output: [
594+
{
595+
"label":"one",
596+
"type":"task",
597+
"nodes":[]
598+
},
599+
{
600+
"label":"two",
601+
"type":"task",
602+
"nodes":[]
603+
},
604+
{
605+
"label":"three",
606+
"type":"task",
607+
"nodes":[]
608+
},
609+
{
610+
"label":"four",
611+
"type":"task",
612+
"nodes":[
613+
{
614+
"label":"<series>",
615+
"type":"function",
616+
"nodes":[
617+
{
618+
"label":"one",
619+
"type":"task",
620+
"nodes":[]
621+
},
622+
{
623+
"label":"two",
624+
"type":"task",
625+
"nodes":[]
626+
}
627+
]
628+
}
629+
]
630+
},
631+
{
632+
"label":"five",
633+
"type":"task",
634+
"nodes":[
635+
{
636+
"label":"<series>",
637+
"type":"function",
638+
"nodes":[
639+
{
640+
"label":"four",
641+
"type":"task",
642+
"nodes":[
643+
{
644+
"label":"<series>",
645+
"type":"function",
646+
"nodes":[
647+
{
648+
"label":"one",
649+
"type":"task",
650+
"nodes":[]
651+
},
652+
{
653+
"label":"two",
654+
"type":"task",
655+
"nodes":[]
656+
}
657+
]
658+
}
659+
]
660+
},
661+
{
662+
"label":"<parallel>",
663+
"type":"function",
664+
"nodes":[
665+
{
666+
"label":"three",
667+
"type":"task",
668+
"nodes":[]
669+
},
670+
{
671+
"label":"<anonymous>",
672+
"type":"function",
673+
"nodes":[]
674+
}
675+
]
676+
}
677+
]
678+
}
679+
]
680+
}
681+
]
682+
*/
683+
```
684+
685+
538686
[Function.name]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
539687
[gaze]: https://github.com/shama/gaze
540688
[glob-stream]: https://github.com/gulpjs/glob-stream

0 commit comments

Comments
 (0)