<commit_before>'use strict';
/*
 * gulp-ng-template
 * https://github.com/teambition/gulp-ng-template
 *
 * Copyright (c) 2014 <NAME>
 * Licensed under the MIT license.
 */

var util = require('util');
var path = require('path');
var gutil = require('gulp-util');
var through = require('through2');
var packageName = require('./package.json').name;

module.exports = function(options) {
  options = options || {};

  var standalone = options.standalone ? ', []' : '';
  var moduleName = options.moduleName || 'ngTemplates';
  var filePath = options.filePath || 'templates.js';
  var joinedContent = '';
  var headerTpl = '\'use strict\';\n\nangular.module(\'<%= module %>\'<%= standalone %>).run([\'$templateCache\', function($templateCache) {\n\n';
  var contentTpl = '  $templateCache.put(\'<%= name %>\', \'<%= content %>\');\n\n';

  var joinedHeader = gutil.template(headerTpl, {module: moduleName, standalone: standalone, file: ''});

  var joinedFile = new gutil.File({
    cwd: __dirname,
    base: __dirname,
    path: path.join(__dirname, filePath)
  });

  function normalizeName(name) {
    return name.replace(/\\/g, '/');
  }

  function normalizeContent(content) {
    return content.toString('utf8').replace(/\'/g, '\\\'').replace(/\r?\n/g, '\\n');
  }

  return through.obj(function (file, encoding, next) {
    if (file.isNull()) return next();
    if (file.isStream()) return this.emit('error', new gutil.PluginError(packageName,  'Streaming not supported'));

    var name = path.relative(file.base, file.path);
    joinedContent += gutil.template(contentTpl, {
      name: normalizeName(name),
      content: normalizeContent(file.contents),
      file: ''
    });
    next();
  }, function () {
    joinedFile.contents = new Buffer(joinedHeader + joinedContent + '}]);');
    this.push(joinedFile);
    this.push(null);
  });
};
<commit_msg>to use closure<commit_after>'use strict';
/*
 * gulp-ng-template
 * https://github.com/teambition/gulp-ng-template
 *
 * Copyright (c) 2014 <NAME>
 * Licensed under the MIT license.
 */

var util = require('util');
var path = require('path');
var gutil = require('gulp-util');
var through = require('through2');
var packageName = require('./package.json').name;

module.exports = function(options) {
  options = options || {};

  var standalone = options.standalone ? ', []' : '';
  var moduleName = options.moduleName || 'ngTemplates';
  var filePath = options.filePath || 'templates.js';
  var closure = options.closure || false;
  var joinedContent = '';
  var headerTpl = '\'use strict\';\n\nangular.module(\'<%= module %>\'<%= standalone %>).run([\'$templateCache\', function($templateCache) {\n\n';
  var contentTpl = '  $templateCache.put(\'<%= name %>\', \'<%= content %>\');\n\n';

  var joinedHeader = gutil.template(headerTpl, {module: moduleName, standalone: standalone, file: ''});

  var joinedFile = new gutil.File({
    cwd: __dirname,
    base: __dirname,
    path: path.join(__dirname, filePath)
  });

  function normalizeName(name) {
    return name.replace(/\\/g, '/');
  }

  function normalizeContent(content) {
    return content.toString('utf8').replace(/\'/g, '\\\'').replace(/\r?\n/g, '\\n');
  }

  return through.obj(function (file, encoding, next) {
    if (file.isNull()) return next();
    if (file.isStream()) return this.emit('error', new gutil.PluginError(packageName,  'Streaming not supported'));

    var name = path.relative(file.base, file.path);
    joinedContent += gutil.template(contentTpl, {
      name: normalizeName(name),
      content: normalizeContent(file.contents),
      file: ''
    });
    next();
  }, function () {
    var content = joinedHeader + joinedContent + '}]);';
    if (closure) {
        content = '(function() {' + content + '})();';
    }
    joinedFile.contents = new Buffer(content);
    this.push(joinedFile);
    this.push(null);
  });
};

{'fraction_non_alphanumeric': 0.19298245614035087, 'fraction_numerical': 0.0030959752321981426, 'mean_word_length': 3.7050970873786406, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '578492', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1219, 'n_words': 266}