run-processors.js 407 B

12345678910111213141516
  1. /**
  2. * Run processors
  3. */
  4. module.exports = function runProcessors(contents, processor, file, count) {
  5. const processors = Array.isArray(processor) ? processor : [processor];
  6. const result = {file};
  7. const newContents = processors.reduce((contents, processor, i) => {
  8. return processor(contents);
  9. }, contents);
  10. result.hasChanged = (newContents !== contents);
  11. return [result, newContents];
  12. };