<commit_before>'use strict';

var generateAngularTemplate = require('generate-angular-template');

// Adds html tempalate in $templateCache and writes file to destFile
//
// $templateCache key is the filepath passed in as srcFile:
//   options.prependPrefix + options.srcFile.replace(stripPrefix, '')
//
// grunt.initConfig({
//   ngtemplatecache: {
//     app: {
//       options: {
//         stripPrefix: ''
//         prependPrefix: '',
//         cacheIdFromPath: function(filepath) {
//           // gets set as $tempalteCache key
//           return filepath;
//         }
//       },
//       files: {
//         destFile: srcFile
//       }
//     }
//   }
// });

module.exports = function(grunt) {
  grunt.task.registerMultiTask('ngtemplatecache',
    'Put angular templates in $templateCache.', function() {

    var options = this.options({
      prependPrefix: '',
      stripPrefix: ''
    });

    var stripPrefix = new RegExp('^' + options.stripPrefix);
    var prependPrefix = options.prependPrefix;
    var cacheIdFromPath = options.cacheIdFromPath ||function (filepath) {
      return prependPrefix + filepath.replace(stripPrefix, '');
    };

    this.files.map(function(el) {
      var filepath = el.src[0];
      var htmlPath = cacheIdFromPath(filepath);
      var content = grunt.file.read(filepath);
      var template = generateAngularTemplate({
        moduleName: options.moduleName,
        htmlPath: htmlPath,
        content: content
      });

      grunt.file.write(el.dest, template);
    });

  });
};
<commit_msg>Refacto to support src globbing into dest file<commit_after>'use strict';

var generateAngularTemplate = require('generate-angular-template');

// Adds html tempalate in $templateCache and writes file to destFile
//
// $templateCache key is the filepath passed in as srcFile:
//   options.prependPrefix + options.srcFile.replace(stripPrefix, '')
//
// grunt.initConfig({
//   ngtemplatecache: {
//     app: {
//       options: {
//         stripPrefix: ''
//         prependPrefix: '',
//         cacheIdFromPath: function(filepath) {
//           // gets set as $tempalteCache key
//           return filepath;
//         }
//       },
//       files: {
//         destFile: srcFile
//       }
//     }
//   }
// });

module.exports = function(grunt) {
  grunt.task.registerMultiTask('ngtemplatecache',
    'Put angular templates in $templateCache.', function() {

    var options = this.options({
      separator: grunt.util.linefeed,
      prependPrefix: '',
      stripPrefix: ''
    });

    var stripPrefix = new RegExp('^' + options.stripPrefix);
    var prependPrefix = options.prependPrefix;
    var cacheIdFromPath = options.cacheIdFromPath ||function (filepath) {
      return prependPrefix + filepath.replace(stripPrefix, '');
    };

    this.files.forEach(function(file) {
      var src = file.src.filter(function(filepath) {
        if (!grunt.file.exists(filepath)) {
          grunt.log.warn('Source file "' + filepath + '" not found.');
          return false;
        } else {
          return true;
        }
      }).map(function(filepath) {
        var htmlPath = cacheIdFromPath(filepath);
        var content = grunt.file.read(filepath);
        var template = generateAngularTemplate({
          moduleName: options.moduleName,
          htmlPath: htmlPath,
          content: content
        });

        return template;
      }).join(options.separator);

      // Write the destination file.
      grunt.file.write(file.dest, src);

      // Print a success message.
      grunt.log.writeln('Template "' + file.dest + '" created.');
    });

  });
};

{'fraction_non_alphanumeric': 0.13809261300992282, 'fraction_numerical': 0.0002756339581036384, 'mean_word_length': 2.3232600732600734, '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': '3712197', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1047, 'n_words': 226}