<commit_before>//Import dependencies
var rmr = require('rmr');
var gulp = require('gulp');
var path = require('path');
var svgstore = require('gulp-svgstore');
var svgmin = require('gulp-svgmin');
var rename = require("gulp-rename");
var handlebars = require('gulp-compile-handlebars');
var fs = require('fs');

//Clean the dist folder
gulp.task('clean', function()
{
  //Clean the dist folder
  return rmr.sync('./dist');
});

//Build the svg sprite task
gulp.task('sprite', function()
{
  //Get the svg files
  gulp.src('./svg/*.svg', { base: './src' })

  //Minimize each file
  .pipe(svgmin(function(file)
  {
    //Get the icon prefix
    var prefix = path.basename(file.relative, path.extname(file.relative));

    //Display in console
    console.log('Processing ' + prefix);

    //Return the prefix plugin
    return { plugins: [ { cleanupIDs: { prefix: prefix + '-',  minify: true } } ] };
  }))

  //Build the sprite
  .pipe(svgstore())<commit_msg>gulpfile.js: added tasks to build font in svg, ttf and woff2 formats<commit_after>//Import dependencies
var rmr = require('rmr');
var fs = require('fs');
var path = require('path');
var gulp = require('gulp');
var svgstore = require('gulp-svgstore');
var svgmin = require('gulp-svgmin');
var rename = require("gulp-rename");
var handlebars = require('gulp-compile-handlebars');
var SVGIcons2SVGFontStream = require('svgicons2svgfont');
var svg2ttf = require('gulp-svg2ttf');
var ttf2woff2 = require('gulp-ttf2woff2');
var utily = require('utily');

//Clean the dist folder
gulp.task('clean', function()
{
  //Clean the dist folder
  return rmr.sync('./dist');
});

//Build the font task
gulp.task('build-font-svg', function()
{
  //Create the new font stream
  var fontStream = new SVGIcons2SVGFontStream({ fontName: 'siimple-icons', normalize: true, fontHeight: 1000 });

  //Setting the font destination
  fontStream.pipe(fs.createWriteStream('dist/siimple-icons.font.svg'));

  //Error event
  fontStream.on('error', function(error){ console.log(error); });

  //Read the icons list
  utily.json.read('./icons.json', function(error, icons)
  {
    //Check the error
    if(error){ throw error; }

    //For each icon object in the list
    icons.forEach(function(icon)
    {
      //Get the icon readable stream
      var reader = fs.createReadStream(icon.path);

      //Set the icon metadata
      reader.metadata = { unicode: [ icon.unicode ], name: icon.id };

      //Write the icon
      fontStream.write(reader);
    });

    //End the stream
    fontStream.end();
  });
});

//Build font in ttf formt
gulp.task('build-font-ttf', function()
{
  //Convert the svg font to ttf
  gulp.src('./dist/siimple-icons.font.svg').pipe(svg2ttf()).pipe(gulp.dest('./dist'));
});

//Build font in woff2 format
gulp.task('build-font-woff2', function()
{
  //Convert the ttf font to woff2
  gulp.src('./dist/siimple-icons.font.ttf').pipe(ttf2woff2()).pipe(gulp.dest('./dist'));
});

//Build the svg sprite task
gulp.task('sprite', function()
{
  //Get the svg files
  gulp.src('./svg/*.svg', { base: './src' })

  //Minimize each file
  .pipe(svgmin(function(file)
  {
    //Get the icon prefix
    var prefix = path.basename(file.relative, path.extname(file.relative));

    //Display in console
    console.log('Processing ' + prefix);

    //Return the prefix plugin
    return { plugins: [ { cleanupIDs: { prefix: prefix + '-',  minify: true } } ] };
  }))

  //Build the sprite
  .pipe(svgstore())
{'fraction_non_alphanumeric': 0.1710564399421129, 'fraction_numerical': 0.005788712011577424, 'mean_word_length': 3.541392904073587, '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': '1814233', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1135, 'n_words': 295}