<commit_before>let path = require('path');
let fs = require('fs-extra');
let Promise = require('bluebird');
let copy = Promise.promisify(fs.copy);

async function generatePlainCssPreprocessor(params) {
  let cssPreprocessorModule = path.join(__base, 'modules', 'css-preprocessor');
  let normalizeCss = path.join(cssPreprocessorModule, 'normalize.css');
  let mainCss = path.join(cssPreprocessorModule, 'main.css');

  switch (params.framework) {
    case 'express':
      let cssDir = path.join(__base, 'build', params.uuid, 'public', 'stylesheets');
      await copy(normalizeCss, path.join(cssDir, 'normalize.css'));
      await copy(mainCss, path.join(cssDir, 'main.css'));
      break;
    case 'hapi':
      // TODO
      break;
    case 'sails':
      // TODO
      break;
    default:
    // TODO
  }
}

module.exports = generatePlainCssPreprocessor;<commit_msg>Refactored generatePlainCssPreprocessor<commit_after>let path = require('path');
let fs = require('fs-extra');
let Promise = require('bluebird');
let copy = Promise.promisify(fs.copy);
let removeCode = require('../../utils/removeCode');
let replaceCode = require('../../utils/replaceCode');


async function generatePlainCssPreprocessor(params) {
  let build = path.join(__base, 'build', params.uuid);
  let normalizeCss = path.join(__base, 'modules', 'css-preprocessor', 'normalize.css');
  let mainCss = path.join(__base, 'modules', 'css-preprocessor', 'main.css');

  switch (params.framework) {
    case 'express':
      let layout = path.join(build, 'views', 'layout.jade');
      let cssImport = path.join(__base, 'modules', 'css-preprocessor', 'express-jade-import.jade');

      await addTemplateImport(params, layout, cssImport);
      await copy(normalizeCss, path.join(build, 'public', 'stylesheets', 'normalize.css'));
      await copy(mainCss, path.join(build, 'public', 'stylesheets', 'main.css'));
      break;
    case 'hapi':
      // TODO
      break;
    case 'sails':
      // TODO
      break;
    default:
    // TODO
  }
}

// move to utils

async function addTemplateImport(params, layout, templateImport) {
  switch (params.templateEngine) {
    case 'jade':
      await replaceCode(layout, 'CSS_PREPROCESSOR_IMPORT', templateImport, { indentLevel: 2 });
      break;
    case 'handlebars':
      // TODO
      break;
    case 'swig':
      // TODO
      break;
    default:
      // TODO
  }
}



module.exports = generatePlainCssPreprocessor;
{'fraction_non_alphanumeric': 0.15006150061500614, 'fraction_numerical': 0.0004100041000410004, 'mean_word_length': 3.5692883895131087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5215082', 'n_tokens_mistral': 770, 'n_tokens_neox': 764, 'n_words': 171}