<commit_before>var universal = require('angular2-universal-preview');
var gulp = require('gulp');
var through = require('through2');
var gutil = require('gutil');

var PluginError = gutil.PluginError;

module.exports = function gulpAngular2Render(config) {
  return through.obj(function transform(file, enc, cb) {
    if (file.isStream()) {
      return cb(new PluginError('angular2-gulp-prerender', 'Streaming is not supported'));
    }
    var str = file.contents.toString();

    var renderPromise = universal.renderToString;
    var args = [config.App, config.providers];
    if (config.preboot) {
      renderPromise = universal.renderToStringWithPreboot;
      args.push(config.preboot);
    }

    renderPromise.apply(null, args)
    .then(function(serializedApp) {

      file.path = gutil.replaceExtension(file.path, '.html');

      var html = str.replace(
        // <selector></selector>
        selectorRegExpFactory(selectorResolver(config.App)),
        // <selector>{{ serializedCmp }}</selector>
        serializedApp
      );

      file.contents = new Buffer(html);

      cb(null, file)
    });
  });<commit_msg>fix(gulp-prerender): undefined<commit_after>var universal = require('angular2-universal-preview');
var gulp = require('gulp');
var through = require('through2');
var gutil = require('gutil');

var PluginError = gutil.PluginError;

module.exports = function gulpAngular2Render(config) {
  return through.obj(function transform(file, enc, cb) {
    if (file.isStream()) {
      return cb(new PluginError('angular2-gulp-prerender', 'Streaming is not supported'));
    }
    var str = file.contents.toString();

    var renderPromise = universal.renderToString;
    var args = [config.App, config.providers];
    if (config.preboot) {
      renderPromise = universal.renderToStringWithPreboot;
      args.push(config.preboot);
    }

    renderPromise.apply(null, args)
    .then(function(serializedApp) {

      file.path = gutil.replaceExtension(file.path, '.html');

      var html = str.replace(
        // <selector></selector>
        selectorRegExpFactory(universal.selectorResolver(config.App)),
        // <selector>{{ serializedCmp }}</selector>
        serializedApp
      );

      file.contents = new Buffer(html);

      cb(null, file)
    });
  });
{'fraction_non_alphanumeric': 0.13749454386730686, 'fraction_numerical': 0.003491924923614142, 'mean_word_length': 3.4591439688715955, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3003599', 'n_tokens_mistral': 685, 'n_tokens_neox': 662, 'n_words': 135}