tree()#

現在のタスク依存関係ツリーを取得します。これは、まれに必要となる場合に利用されます。

一般的に、tree()はgulpのユーザーによって使用されることはありませんが、gulpfileで定義されたタスクの依存関係グラフをCLIが表示できるように公開されています。

使用法#

gulpfileの例

const { series, parallel } = require('gulp');
function one(cb) {
// 中身は省略
cb();
}
function two(cb) {
// 中身は省略
cb();
}
function three(cb) {
// 中身は省略
cb();
}
const four = series(one, two);
const five = series(four,
parallel(three, function(cb) {
// 中身は省略
cb();
})
);
module.exports = { one, two, three, four, five };

tree()の出力

{
label: 'タスク',
nodes: [ 'one', 'two', 'three', 'four', 'five' ]
}

tree({ deep: true })の出力

{
label: "タスク",
nodes: [
{
label: "one",
type: "task",
nodes: []
},
{
label: "two",
type: "task",
nodes: []
},
{
label: "three",
type: "task",
nodes: []
},
{
label: "four",
type: "task",
nodes: [
{
label: "<series>",
type: "function",
branch: true,
nodes: [
{
label: "one",
type: "function",
nodes: []
},
{
label: "two",
type: "function",
nodes: []
}
]
}
]
},
{
label: "five",
type: "task",
nodes: [
{
label: "<series>",
type: "function",
branch: true,
nodes: [
{
label: "<series>",
type: "function",
branch: true,
nodes: [
{
label: "one",
type: "function",
nodes: []
},
{
label: "two",
type: "function",
nodes: []
}
]
},
{
label: "<parallel>",
type: "function",
branch: true,
nodes: [
{
label: "three",
type: "function",
nodes: []
},
{
label: "<anonymous>",
type: "function",
nodes: []
}
]
}
]
}
]
}
]
}

シグネチャ#

tree([options])

パラメータ#

パラメータタイプ
optionsオブジェクト詳細は、下記のオプションを参照してください。

戻り値#

登録されたタスクのツリーを詳細に記述したオブジェクトです。'label''nodes'プロパティを持つネストされたオブジェクトを含みます(これはarchyと互換性があります)。

各オブジェクトは、ノードがtaskfunctionかを判断するために使用できるtypeプロパティを持つ場合があります。

各オブジェクトは、trueの場合、ノードがseries()またはparallel()を使用して作成されたことを示すbranchプロパティを持つ場合があります。

オプション#

nameタイプdefault
deepbooleanfalsetrueの場合、ツリー全体が返されます。falseの場合、トップレベルのタスクのみが返されます。