<commit_before>'use strict';

var fs = require('fs');
var path = require('path');

var templatesTask = function (gulp, plugins, config, helpers) {

  function getTemplateInputData(file) {
    try {
      var data = JSON.parse(
        fs.readFileSync(
          path.join(config.src.dataPath, path.basename(file.path) + '.json')
        )
      );
    } catch (error) {
      // Mute errors related to missing input data & log all other
      if (error.code === 'ENOENT') {
        console.error(error);
      }
    }
    return data || {};
  }

  function templates(manifest) {
    var buildIncludedGlobs = config.src.templatesBuild || '';
    var buildIncludedFilter = plugins.filter(buildIncludedGlobs);

    return gulp.src(config.src.templatesWatch)
      .on('end', plugins.browserSync.reload)
      .pipe(plugins.plumber(helpers.onError))
      .pipe(buildIncludedFilter)
      .pipe(plugins.data(getTemplateInputData))
      .pipe(plugins.twigUpToDate({
        base: config.src.templatesPath,
        functions: [
          {
            name: "assetPath",
            func: function (path) {
              if (manifest) {
                return manifest[path];
              } else {
                return path;
              }
            }
          }
        ],
        errorLogToConsole: true
      }))<commit_msg>Fix #71. Mute missing data file, log other errors<commit_after>'use strict';

var fs = require('fs');
var path = require('path');

var templatesTask = function (gulp, plugins, config, helpers) {

  function getTemplateInputData(file) {
    try {
      var data = JSON.parse(
        fs.readFileSync(
          path.join(config.src.dataPath, path.basename(file.path) + '.json')
        )
      );
    } catch (error) {
      // Mute errors related to missing input data & log all other
      if (error.code !== 'ENOENT') {
        console.error(error);
      }
    }
    return data || {};
  }

  function templates(manifest) {
    var buildIncludedGlobs = config.src.templatesBuild || '';
    var buildIncludedFilter = plugins.filter(buildIncludedGlobs);

    return gulp.src(config.src.templatesWatch)
      .on('end', plugins.browserSync.reload)
      .pipe(plugins.plumber(helpers.onError))
      .pipe(buildIncludedFilter)
      .pipe(plugins.data(getTemplateInputData))
      .pipe(plugins.twigUpToDate({
        base: config.src.templatesPath,
        functions: [
          {
            name: "assetPath",
            func: function (path) {
              if (manifest) {
                return manifest[path];
              } else {
                return path;
              }
            }
          }
        ],
        errorLogToConsole: true
      }))
{'fraction_non_alphanumeric': 0.12138084632516703, 'fraction_numerical': 0.0007423904974016332, 'mean_word_length': 2.0011135857461024, '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': '6979702', 'n_tokens_mistral': 784, 'n_tokens_neox': 768, 'n_words': 160}