<commit_before>/* jshint node: true */
'use strict';
var path = require('path');
var optimizeJs = require('broccoli-optimize-js');
var funnel = require('broccoli-funnel');
var mergeTrees = require('broccoli-merge-trees');
var uniq = require('lodash.uniq');
var assign = require('lodash.assign');

function wrapConcatInput(app, tree, concatOpts) {
  if (path.extname(concatOpts.outputFile) !== '.js') {
    return tree;
  }

  var sourceMap = app.options.sourcemaps.enabled;
  var eager = app.env === 'production';
  var minify;
  if (app.options.minifyJS.enabled) {
    minify = assign({
      mangle: true,
      compress: true
    }, app.options.minifyJS.options);
  }

  if (!minify && !eager) {
    return tree;
  }

  var include = uniq([].concat(concatOpts.headerFiles || [], concatOpts.inputFiles || [], concatOpts.footerFiles || []));

  var js = funnel(tree, {
    include: include
  });

  return mergeTrees([tree, optimizeJs(js, {
    eager: eager,
    mangle: minify.mangle,
    compress: minify.compress,
    output: minify.output,
    sourceMap: sourceMap
  })], {
    overwrite: true
  });
}

module.exports = {
  name: 'ember-cli-optimize',
  included: function (app) {
    this._super.included.apply(this, arguments);
    if (app.project.findAddonByName('ember-cli-uglify')) {
      this.ui.writeWarnLine('not compatible with ember-cli-uglify');
      return;
    }
    var origConcatFiles = app.concatFiles;
    app.concatFiles = function (tree, options) {
      var args = Array(arguments.length);
      for (args, i = 0; i < arguments.length; i++) args[i] = arguments[i];
      var tree = args[0];
      var options = args[1];
      args[0] = wrapConcatInput(app, tree, options);
      return origConcatFiles.apply(this, args);
    };
  },
  afterInstall: function () {
    return this.removePackageFromProject('ember-cli-uglify');
  }
};<commit_msg>fix slight refactor<commit_after>/* jshint node: true */
'use strict';
var path = require('path');
var optimizeJs = require('broccoli-optimize-js');
var funnel = require('broccoli-funnel');
var mergeTrees = require('broccoli-merge-trees');
var uniq = require('lodash.uniq');
var assign = require('lodash.assign');

function wrapConcatInput(app, tree, concatOpts) {
  if (path.extname(concatOpts.outputFile) !== '.js') {
    return tree;
  }

  var sourceMap = app.options.sourcemaps.enabled;
  var eager = app.env === 'production';
  var minify;
  if (app.options.minifyJS.enabled) {
    minify = assign({
      mangle: true,
      compress: true
    }, app.options.minifyJS.options);
  }

  if (!minify && !eager) {
    return tree;
  }

  var include = uniq([].concat(concatOpts.headerFiles || [], concatOpts.inputFiles || [], concatOpts.footerFiles || []));

  var js = funnel(tree, {
    include: include
  });

  return mergeTrees([tree, optimizeJs(js, {
    eager: eager,
    mangle: minify.mangle,
    compress: minify.compress,
    output: minify.output,
    sourceMap: sourceMap
  })], {
    overwrite: true
  });
}

module.exports = {
  name: 'ember-cli-optimize',
  included: function (app) {
    this._super.included.apply(this, arguments);
    if (app.project.findAddonByName('ember-cli-uglify')) {
      this.ui.writeWarnLine('not compatible with ember-cli-uglify');
      return;
    }
    var origConcatFiles = app.concatFiles;
    app.concatFiles = function (tree, options) {
      var args = Array(arguments.length);
      for (var i = 0; i < arguments.length; i++) args[i] = arguments[i];
      var tree = args[0];
      var options = args[1];
      args[0] = wrapConcatInput(app, tree, options);
      return origConcatFiles.apply(this, args);
    };
  },
  afterInstall: function () {
    return this.removePackageFromProject('ember-cli-uglify');
  }
};
{'fraction_non_alphanumeric': 0.15518162393162394, 'fraction_numerical': 0.002136752136752137, 'mean_word_length': 3.463647199046484, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2153025', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1246, 'n_words': 266}