normalizeArgs.js 559 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. var assert = require('assert');
  3. var map = require('arr-map');
  4. var flatten = require('arr-flatten');
  5. function normalizeArgs(registry, args) {
  6. function getFunction(task) {
  7. if (typeof task === 'function') {
  8. return task;
  9. }
  10. var fn = registry.get(task);
  11. assert(fn, 'Task never defined: ' + task);
  12. return fn;
  13. }
  14. var flattenArgs = flatten(args);
  15. assert(flattenArgs.length, 'One or more tasks should be combined using series or parallel');
  16. return map(flattenArgs, getFunction);
  17. }
  18. module.exports = normalizeArgs;