import {execute as runPreprocessor} from '../preprocessors'

/**
 * Preprocess a riot parser node
 * @param   { string } preprocessorType - either css, js
 * @param   { string } preprocessorName - preprocessor id
 * @param   { Object } meta - compilation meta information
 * @param   { RiotParser.nodeTypes } node - css node detected by the parser
 * @returns { Output } code and sourcemap generated by the preprocessor
 */
export default function preprocess(preprocessorType, preprocessorName, meta, node) {
  const code = node.text

  return (preprocessorName ?
    runPreprocessor(preprocessorType, preprocessorName, meta, code) :
    { code }
  )
}