tree.js 504 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. var defaults = require('object.defaults');
  3. var map = require('collection-map');
  4. var metadata = require('./helpers/metadata');
  5. function tree(opts) {
  6. opts = defaults(opts || {}, {
  7. deep: false,
  8. });
  9. var tasks = this._registry.tasks();
  10. var nodes = map(tasks, function(task) {
  11. var meta = metadata.get(task);
  12. if (opts.deep) {
  13. return meta.tree;
  14. }
  15. return meta.tree.label;
  16. });
  17. return {
  18. label: 'Tasks',
  19. nodes: nodes,
  20. };
  21. }
  22. module.exports = tree;