<commit_before>var fs = require('fs');
var path = require('path');
var _ = require('lodash');

module.exports = function(grunt) {
  grunt.initConfig({
    sass: {
      dist: {
        files: {
          'css/videojs-icons.css': 'scss/videojs-icons.scss'
        }
      }
    },
    watch: {
      all: {
        files: ['**/*.hbs', '**/*.js', './icons.json'],
        tasks: ['default']
      }
    }
  });

  grunt.registerTask('generate-font', function() {
    var done = this.async();

    let webfontsGenerator = require('webfonts-generator');
    let iconConfig = require('../icons.json');
    let svgRootDir = iconConfig['root-dir'];
    let icons = iconConfig.icons;

    let iconFiles = icons.map(function(icon) {
      // If root-dir is specified for a specific icon, use that.
      if (icon['root-dir']) {
        return icon['root-dir'] + icon.svg;
      }

      // Otherwise, use the default root-dir.
      return svgRootDir + icon.svg;
    });

    webfontsGenerator({
      files: iconFiles,
      dest: 'fonts/',
      fontName: iconConfig['font-name'],
      cssDest: 'scss/_icons.scss',
      cssTemplate: './templates/scss.hbs',
      htmlDest: 'preview.html',
      htmlTemplate: './templates/html.hbs',
      html: true,
      rename: function(iconPath) {
        let fileName = path.basename(iconPath);

        let iconName = _.result(_.find(icons, function(icon) {
          let svgName = path.basename(icon.svg);

          return svgName === fileName;
        }), 'name');

        return iconName;
      },
      types: ['svg', 'ttf', 'woff', 'eot']
    }, function(error) {
      if (error) {
        console.error(error);
        done(false);
      }

      done();
    });

  });

  grunt.registerTask('wrapcodepoints', function() {
    const cssPath = path.normalize('./css/videojs-icons.css');
    const css = grunt.file.read(cssPath);
    grunt.file.write(cssPath, css.replace(/(\\f\w+);/g, "'$1'"));
  });

  grunt.registerTask('update-base64', function() {
    let iconScssFile = './scss/_icons.scss';
    let fontFiles = {
      ttf: './fonts/VideoJS.ttf',
      woff: './fonts/VideoJS.woff'
    };

    let scssContents = fs.readFileSync(iconScssFile).toString();

    Object.keys(fontFiles).forEach(function(font) {
      let fontFile = fontFiles[font];
      let fontContent = fs.readFileSync(fontFile);

      let regex = new RegExp(`(url.*font-${font}.*base64,)([^\\s]+)(\\).*)`);

      scssContents = scssContents.replace(regex, `$1${fontContent.toString('base64')}$3`);
    });

    fs.writeFileSync(iconScssFile, scssContents);
  });

  grunt.registerTask('default', ['generate-font', 'update-base64', 'sass', 'wrapcodepoints']);
};<commit_msg>re-add semicolon. Add comment to new grunt task<commit_after>var fs = require('fs');
var path = require('path');
var _ = require('lodash');

module.exports = function(grunt) {
  grunt.initConfig({
    sass: {
      dist: {
        files: {
          'css/videojs-icons.css': 'scss/videojs-icons.scss'
        }
      }
    },
    watch: {
      all: {
        files: ['**/*.hbs', '**/*.js', './icons.json'],
        tasks: ['default']
      }
    }
  });

  grunt.registerTask('generate-font', function() {
    var done = this.async();

    let webfontsGenerator = require('webfonts-generator');
    let iconConfig = require('../icons.json');
    let svgRootDir = iconConfig['root-dir'];
    let icons = iconConfig.icons;

    let iconFiles = icons.map(function(icon) {
      // If root-dir is specified for a specific icon, use that.
      if (icon['root-dir']) {
        return icon['root-dir'] + icon.svg;
      }

      // Otherwise, use the default root-dir.
      return svgRootDir + icon.svg;
    });

    webfontsGenerator({
      files: iconFiles,
      dest: 'fonts/',
      fontName: iconConfig['font-name'],
      cssDest: 'scss/_icons.scss',
      cssTemplate: './templates/scss.hbs',
      htmlDest: 'preview.html',
      htmlTemplate: './templates/html.hbs',
      html: true,
      rename: function(iconPath) {
        let fileName = path.basename(iconPath);

        let iconName = _.result(_.find(icons, function(icon) {
          let svgName = path.basename(icon.svg);

          return svgName === fileName;
        }), 'name');

        return iconName;
      },
      types: ['svg', 'ttf', 'woff', 'eot']
    }, function(error) {
      if (error) {
        console.error(error);
        done(false);
      }

      done();
    });

  });

  // Sass turns unicode codepoints into utf8 characters.
  // We don't want that so we unwrapped them in the templates/scss.hbs file.
  // After sass has generated our css file, we need to wrap the codepoints
  // in quotes for it to work.
  grunt.registerTask('wrapcodepoints', function() {
    const cssPath = path.normalize('./css/videojs-icons.css');
    const css = grunt.file.read(cssPath);
    grunt.file.write(cssPath, css.replace(/(\\f\w+);/g, "'$1';"));
  });

  grunt.registerTask('update-base64', function() {
    let iconScssFile = './scss/_icons.scss';
    let fontFiles = {
      ttf: './fonts/VideoJS.ttf',
      woff: './fonts/VideoJS.woff'
    };

    let scssContents = fs.readFileSync(iconScssFile).toString();

    Object.keys(fontFiles).forEach(function(font) {
      let fontFile = fontFiles[font];
      let fontContent = fs.readFileSync(fontFile);

      let regex = new RegExp(`(url.*font-${font}.*base64,)([^\\s]+)(\\).*)`);

      scssContents = scssContents.replace(regex, `$1${fontContent.toString('base64')}$3`);
    });

    fs.writeFileSync(iconScssFile, scssContents);
  });

  grunt.registerTask('default', ['generate-font', 'update-base64', 'sass', 'wrapcodepoints']);
};
{'fraction_non_alphanumeric': 0.17629394099982335, 'fraction_numerical': 0.004062886415827592, 'mean_word_length': 2.581277672359266, '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': '48340', 'n_tokens_mistral': 1912, 'n_tokens_neox': 1872, 'n_words': 363}