get-task.js 879 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. var isObject = require('isobject');
  3. function getTask(gulpInst) {
  4. return function(name) {
  5. var task = gulpInst.task(name);
  6. return {
  7. description: getDescription(task),
  8. flags: getFlags(task),
  9. };
  10. };
  11. }
  12. function getDescription(task) {
  13. if (typeof task.description === 'string') {
  14. return task.description;
  15. }
  16. /* istanbul ignore else */
  17. if (typeof task.unwrap === 'function') {
  18. var origFn = task.unwrap();
  19. if (typeof origFn.description === 'string') {
  20. return origFn.description;
  21. }
  22. }
  23. return undefined;
  24. }
  25. function getFlags(task) {
  26. if (isObject(task.flags)) {
  27. return task.flags;
  28. }
  29. /* istanbul ignore else */
  30. if (typeof task.unwrap === 'function') {
  31. var origFn = task.unwrap();
  32. if (isObject(origFn.flags)) {
  33. return origFn.flags;
  34. }
  35. }
  36. return undefined;
  37. }
  38. module.exports = getTask;