<commit_before>var gutil = require('gulp-util'),
    _ = require('lodash'),
    path = require('path'),
    through = require('through'),
    UglifyJS = require('uglify-js');

var File = gutil.File,
    PluginError = gutil.PluginError;

module.exports = function(filename, options) {
  'use strict';

  var baseFile = null,
      basePath = '.',
      toplevel = null,
      sourcesContent = {};

  if (typeof filename === 'object') {
    // options given, but no filename
    options = filename;
    filename = null;
  }

  // Assign default values to options
  options = _.extend({
    compress: {
      warnings: false
    },
    mangle: {},
    output: {},
  }, options);

  // Needed to get the relative paths correct in the source map
  if (options.basePath) {
    basePath = process.cwd() + path.sep + options.basePath;
  }

  function bufferFiles(file) {
    /* jshint validthis: true */
    if (file.isNull()) return;

    if (file.isStream()) {
      return this.emit('error', new PluginError('gulp-uglifyjs',  'Streaming not supported'));
    }

    if (!baseFile) {
      baseFile = file;

      // Set the filename if one wasn't given
      if (!filename) {
        filename = baseFile.relative;
      }

      // Set the outSourceMap filename if one was requested
      if (options.outSourceMap === true) {
        options.outSourceMap = filename + '.map';
      }
    }

    var code = file.contents.toString();

    sourcesContent[file.path] = code;

    try {
      toplevel = UglifyJS.parse(code, {
        filename: path.relative(basePath, file.path),
        toplevel: toplevel
      });
    } catch(e) {
      gutil.log('gulp-uglifyjs - UglifyJS threw an error');
      gutil.log(gutil.colors.red('file: ') + file.path + ':' + e.line + ',' + e.col);
      gutil.log(gutil.colors.red('error: ') + e.message);

      return this.emit('error', new PluginError('gulp-uglifyjs',  'Aborting due to previous errors'));
    }
  }

  function minify() {
    /* jshint validthis: true, camelcase: false */
    if(!toplevel) {
      gutil.log('gulp-uglifyjs - No files given; aborting minification');
      return;
    }

    if (options.wrap) {
      toplevel = toplevel.wrap_commonjs(options.wrap, options.exportAll);
    }

    if (options.enclose) {
      var argParameterList = _.map(options.enclose, function(val, key) {
        return key + ':' + val;
      });

      toplevel = toplevel.wrap_enclose(argParameterList);
    }

    toplevel.figure_out_scope();

    if (options.compress !== false) {
      var compressor = UglifyJS.Compressor(options.compress);
      toplevel = toplevel.transform(compressor);

      toplevel.figure_out_scope();
    }

    if (options.mangle !== false) {
      toplevel.mangle_names();
    }

    if (options.outSourceMap) {
      options.output.source_map = options.output.source_map || {
        file: filename,
        root: baseFile.cwd,
      };

      var map = UglifyJS.SourceMap(options.output.source_map);
      options.output.source_map = map;

      if (options.sourceMapIncludeSources) {
        for (var file in sourcesContent) {
          if (sourcesContent.hasOwnProperty(file)) {
            options.output.source_map.get().setSourceContent(file, sourcesContent[file]);
          }
        }
      }
    }

    // Output the minified code
    var stream = UglifyJS.OutputStream(options.output);
    toplevel.print(stream);
    var min = stream.get();

    if (options.outSourceMap) {
      // Manually add source map comment to uglified code
      min += '\r\n//# sourceMappingURL=' + options.outSourceMap;
    }

    var compressedFile = new File({
      cwd: baseFile.cwd,
      base: baseFile.base,
      path: path.join(baseFile.base, filename),<commit_msg>added inSourceMap option<commit_after>var gutil = require('gulp-util'),
    _ = require('lodash'),
    path = require('path'),
    through = require('through'),
    UglifyJS = require('uglify-js'),
    fs = require('fs');

var File = gutil.File,
    PluginError = gutil.PluginError;

module.exports = function(filename, options) {
  'use strict';

  var baseFile = null,
      basePath = '.',
      toplevel = null,
      sourcesContent = {};

  if (typeof filename === 'object') {
    // options given, but no filename
    options = filename;
    filename = null;
  }

  // Assign default values to options
  options = _.extend({
    compress: {
      warnings: false
    },
    mangle: {},
    output: {},
  }, options);

  // Needed to get the relative paths correct in the source map
  if (options.basePath) {
    basePath = process.cwd() + path.sep + options.basePath;
  }

  function bufferFiles(file) {
    /* jshint validthis: true */
    if (file.isNull()) return;

    if (file.isStream()) {
      return this.emit('error', new PluginError('gulp-uglifyjs',  'Streaming not supported'));
    }

    if (!baseFile) {
      baseFile = file;

      // Set the filename if one wasn't given
      if (!filename) {
        filename = baseFile.relative;
      }

      // Set the outSourceMap filename if one was requested
      if (options.outSourceMap === true) {
        options.outSourceMap = filename + '.map';
      }
    }

    var code = file.contents.toString();

    sourcesContent[file.path] = code;

    try {
      toplevel = UglifyJS.parse(code, {
        filename: path.relative(basePath, file.path),
        toplevel: toplevel
      });
    } catch(e) {
      gutil.log('gulp-uglifyjs - UglifyJS threw an error');
      gutil.log(gutil.colors.red('file: ') + file.path + ':' + e.line + ',' + e.col);
      gutil.log(gutil.colors.red('error: ') + e.message);

      return this.emit('error', new PluginError('gulp-uglifyjs',  'Aborting due to previous errors'));
    }
  }

  function minify() {
    /* jshint validthis: true, camelcase: false */
    if(!toplevel) {
      gutil.log('gulp-uglifyjs - No files given; aborting minification');
      return;
    }

    if (options.wrap) {
      toplevel = toplevel.wrap_commonjs(options.wrap, options.exportAll);
    }

    if (options.enclose) {
      var argParameterList = _.map(options.enclose, function(val, key) {
        return key + ':' + val;
      });

      toplevel = toplevel.wrap_enclose(argParameterList);
    }

    toplevel.figure_out_scope();

    if (options.compress !== false) {
      var compressor = UglifyJS.Compressor(options.compress);
      toplevel = toplevel.transform(compressor);

      toplevel.figure_out_scope();
    }

    if (options.mangle !== false) {
      toplevel.mangle_names();
    }

    if (options.outSourceMap) {
      options.output.source_map = options.output.source_map || {
        file: filename,
        root: baseFile.cwd,
      };
      if (options.inSourceMap) {
        options.output.source_map.orig = fs.readFileSync(options.inSourceMap).toString();
      } 

      var map = UglifyJS.SourceMap(options.output.source_map);
      options.output.source_map = map;

      if (options.sourceMapIncludeSources) {
        for (var file in sourcesContent) {
          if (sourcesContent.hasOwnProperty(file)) {
            options.output.source_map.get().setSourceContent(file, sourcesContent[file]);
          }
        }
      }
    }

    // Output the minified code
    var stream = UglifyJS.OutputStream(options.output);
    toplevel.print(stream);
    var min = stream.get();

    if (options.outSourceMap) {
      // Manually add source map comment to uglified code
      min += '\r\n//# sourceMappingURL=' + options.outSourceMap;
    }

    var compressedFile = new File({
      cwd: baseFile.cwd,
      base: baseFile.base,
      path: path.join(baseFile.base, filename),
{'fraction_non_alphanumeric': 0.13442622950819672, 'fraction_numerical': 0.0, 'mean_word_length': 2.5191508998615597, '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': '2152809', 'n_tokens_mistral': 2456, 'n_tokens_neox': 2388, 'n_words': 519}