<commit_before>var fs = require('fs-extra')
var path = require('path');
var trace = require('./lib/trace');
var folderExists = require('is-existing-folder');

// Step through a object of files and return all file names which match a certain reg exp
function findComponents(branch, regexp, path) {
  path = path || '';
  var matches = [];
  if (branch) {
    Object.keys(branch).forEach(function(name) {
      var leaf = branch[name];

      if (typeof leaf === 'object') {
        var childmatches = findComponents(leaf, regexp, path + name + '/');
        matches = matches.concat(childmatches);
      } else if (name.match(regexp)) {
        matches.push(path + name);
      }
    });
  }

  return matches;
}

// Build scripts for bundling scripts and styles, generating icon-fonts, minifying imagages and copying font files.
module.exports = function build(type, config) {
  console.log('Buildning', type);
  var components = {
    base : config.path.base ? trace(path.join(config.path.dirname, config.path.base)) : false,
    components : config.path.components ? trace(path.join(config.path.dirname, config.path.components)) : false,
    modules : config.path.modules ? trace(path.join(config.path.dirname, config.path.modules)) : false,
    views :  config.path.views ? trace(path.join(config.path.dirname, config.path.views)) : false,
    helpers :  config.path.helpers ? trace(path.join(config.path.dirname, config.path.helpers)) : false
  };

  // Look if folder exists, otherwise create it
  try  {
    return fs.statSync(path.join(config.path.dirname, config.path.dist)).isDirectory();
  }
  catch (e) {
    fs.mkdirSync(path.join(config.path.dirname, config.path.dist));
  };

  if (!type) {
    fs.emptyDirSync(path.join(config.path.dirname, config.path.dist), function (err) {
      if (!err) console.log('Empty DIST')
    });
  }

  if (!type || type === 'icons') {
    console.log('Generating iconfont');

    require('./lib/build-icons')({
      iconSrc: path.join(config.path.dirname, config.path.icons),
      fontName: 'icons',
      fontDest: path.join(config.path.dirname, config.path.fonts),
      cssDest: path.join(config.path.dirname, config.path.base + '/icon/index.css')<commit_msg>removed unfortunate return statement<commit_after>var fs = require('fs-extra')
var path = require('path');
var trace = require('./lib/trace');
var folderExists = require('is-existing-folder');

// Step through a object of files and return all file names which match a certain reg exp
function findComponents(branch, regexp, path) {
  path = path || '';
  var matches = [];
  if (branch) {
    Object.keys(branch).forEach(function(name) {
      var leaf = branch[name];

      if (typeof leaf === 'object') {
        var childmatches = findComponents(leaf, regexp, path + name + '/');
        matches = matches.concat(childmatches);
      } else if (name.match(regexp)) {
        matches.push(path + name);
      }
    });
  }

  return matches;
}

// Build scripts for bundling scripts and styles, generating icon-fonts, minifying imagages and copying font files.
module.exports = function build(type, config) {
  console.log('Buildning', type);
  var components = {
    base : config.path.base ? trace(path.join(config.path.dirname, config.path.base)) : false,
    components : config.path.components ? trace(path.join(config.path.dirname, config.path.components)) : false,
    modules : config.path.modules ? trace(path.join(config.path.dirname, config.path.modules)) : false,
    views :  config.path.views ? trace(path.join(config.path.dirname, config.path.views)) : false,
    helpers :  config.path.helpers ? trace(path.join(config.path.dirname, config.path.helpers)) : false
  };

  // Look if folder exists, otherwise create it
  try  {
    fs.statSync(path.join(config.path.dirname, config.path.dist)).isDirectory();
  }
  catch (e) {
    fs.mkdirSync(path.join(config.path.dirname, config.path.dist));
  };

  if (!type) {
    fs.emptyDirSync(path.join(config.path.dirname, config.path.dist), function (err) {
      if (!err) console.log('Empty DIST')
    });
  }

  if (!type || type === 'icons') {
    console.log('Generating iconfont');

    require('./lib/build-icons')({
      iconSrc: path.join(config.path.dirname, config.path.icons),
      fontName: 'icons',
      fontDest: path.join(config.path.dirname, config.path.fonts),
      cssDest: path.join(config.path.dirname, config.path.base + '/icon/index.css')
{'fraction_non_alphanumeric': 0.15412347904461468, 'fraction_numerical': 0.0, 'mean_word_length': 3.534218590398366, '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': '2712317', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1347, 'n_words': 309}