Skip to content

Commit

Permalink
make the tree API return an object instead of array - closes #24
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Nov 17, 2015
1 parent 6a1948e commit c1cda41
Show file tree
Hide file tree
Showing 7 changed files with 306 additions and 283 deletions.
7 changes: 6 additions & 1 deletion lib/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function tree(opts) {
});

var tasks = this._registry.tasks();
return _.map(tasks, function(task) {
var nodes = _.map(tasks, function(task) {
var meta = metadata.get(task);

if (opts.deep) {
Expand All @@ -19,6 +19,11 @@ function tree(opts) {

return meta.tree.label;
});

return {
label: 'Tasks',
nodes: nodes,
};
}

module.exports = tree;
195 changes: 99 additions & 96 deletions test/fixtures/taskTree/aliasNested.js
Original file line number Diff line number Diff line change
@@ -1,98 +1,101 @@
'use strict';

module.exports = [
{
label: 'noop',
type: 'task',
nodes: []
},
{
label: 'fn1',
type: 'task',
nodes: []
},
{
label: 'fn2',
type: 'task',
nodes: []
},
{
label: 'fn3',
type: 'task',
nodes: []
},
{
label: 'ser',
type: 'task',
nodes: [
{
label: '<series>',
type: 'function',
nodes: [
{
label: 'noop',
type: 'function',
nodes: []
},
{
label: '<anonymous>',
type: 'function',
nodes: []
},
{
label: 'fn1',
type: 'task',
nodes: []
},
{
label: 'fn2',
type: 'task',
nodes: []
},
{
label: 'fn3',
type: 'task',
nodes: []
}
]
}
]
},
{
label: 'par',
type: 'task',
nodes: [
{
label: '<parallel>',
type: 'function',
nodes: [
{
label: 'noop',
type: 'function',
nodes: []
},
{
label: '<anonymous>',
type: 'function',
nodes: []
},
{
label: 'fn1',
type: 'task',
nodes: []
},
{
label: 'fn2',
type: 'task',
nodes: []
},
{
label: 'fn3',
type: 'task',
nodes: []
}
]
}
]
}
];
module.exports = {
label: 'Tasks',
nodes: [
{
label: 'noop',
type: 'task',
nodes: []
},
{
label: 'fn1',
type: 'task',
nodes: []
},
{
label: 'fn2',
type: 'task',
nodes: []
},
{
label: 'fn3',
type: 'task',
nodes: []
},
{
label: 'ser',
type: 'task',
nodes: [
{
label: '<series>',
type: 'function',
nodes: [
{
label: 'noop',
type: 'function',
nodes: []
},
{
label: '<anonymous>',
type: 'function',
nodes: []
},
{
label: 'fn1',
type: 'task',
nodes: []
},
{
label: 'fn2',
type: 'task',
nodes: []
},
{
label: 'fn3',
type: 'task',
nodes: []
}
]
}
]
},
{
label: 'par',
type: 'task',
nodes: [
{
label: '<parallel>',
type: 'function',
nodes: [
{
label: 'noop',
type: 'function',
nodes: []
},
{
label: '<anonymous>',
type: 'function',
nodes: []
},
{
label: 'fn1',
type: 'task',
nodes: []
},
{
label: 'fn2',
type: 'task',
nodes: []
},
{
label: 'fn3',
type: 'task',
nodes: []
}
]
}
]
}
],
};
57 changes: 30 additions & 27 deletions test/fixtures/taskTree/aliasSimple.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
'use strict';

module.exports = [
{
label: 'noop',
type: 'task',
nodes: []
},
{
label: 'fn1',
type: 'task',
nodes: []
},
{
label: 'fn2',
type: 'task',
nodes: []
},
{
label: 'fn3',
type: 'task',
nodes: []
},
{
label: 'fn4',
type: 'task',
nodes: []
}
];
module.exports = {
label: 'Tasks',
nodes: [
{
label: 'noop',
type: 'task',
nodes: []
},
{
label: 'fn1',
type: 'task',
nodes: []
},
{
label: 'fn2',
type: 'task',
nodes: []
},
{
label: 'fn3',
type: 'task',
nodes: []
},
{
label: 'fn4',
type: 'task',
nodes: []
}
],
};
71 changes: 37 additions & 34 deletions test/fixtures/taskTree/doubleLevel.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
'use strict';

module.exports = [
{
label: 'fn1',
type: 'task',
nodes: [],
},
{
label: 'fn2',
type: 'task',
nodes: [],
},
{
label: 'fn3',
type: 'task',
nodes: [
{
label: '<series>',
type: 'function',
nodes: [
{
label: 'fn1',
type: 'task',
nodes: [],
},
{
label: 'fn2',
type: 'task',
nodes: [],
},
],
},
],
},
];
module.exports = {
label: 'Tasks',
nodes: [
{
label: 'fn1',
type: 'task',
nodes: [],
},
{
label: 'fn2',
type: 'task',
nodes: [],
},
{
label: 'fn3',
type: 'task',
nodes: [
{
label: '<series>',
type: 'function',
nodes: [
{
label: 'fn1',
type: 'task',
nodes: [],
},
{
label: 'fn2',
type: 'task',
nodes: [],
},
],
},
],
},
],
};
25 changes: 14 additions & 11 deletions test/fixtures/taskTree/simple.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
'use strict';

module.exports = [
'test1',
'test2',
'test3',
'error',
'ser',
'par',
'serpar',
'serpar2',
'<display name>',
];
module.exports = {
label: 'Tasks',
nodes: [
'test1',
'test2',
'test3',
'error',
'ser',
'par',
'serpar',
'serpar2',
'<display name>',
],
};
Loading

0 comments on commit c1cda41

Please sign in to comment.