This file is indexed.

/usr/lib/nodejs/grunt-contrib-uglify/tasks/uglify.js is in node-grunt-contrib-uglify 2.0.0+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
 * grunt-contrib-uglify
 * http://gruntjs.com/
 *
 * Copyright (c) 2016 "Cowboy" Ben Alman, contributors
 * Licensed under the MIT license.
 */

'use strict';

var path = require('path');
var chalk = require('chalk');
var bytes = require('bytes');
var err;

// replacement for maxmin
// Copyright (c) Paolo Greppi 2016
// MIT license
// based on https://github.com/sindresorhus/maxmin/blob/master/index.js
// - this is a real OS ! patch away figures
// - use node-bytes rather than the unpackaged pretty-bytes
// - skip gzip size
function maxmin(max, min, useGzip) {
  var ret = chalk.green(bytes(typeof max === 'number' ? max : max.length)) + ' → ' + chalk.green(bytes(typeof min === 'number' ? min : min.length));
  return ret;
}

// Return the relative path from file1 => file2
function relativePath(file1, file2) {
  var file1Dirname = path.dirname(file1);
  var file2Dirname = path.dirname(file2);

  if (file1Dirname !== file2Dirname) {
    return path.relative(file1Dirname, file2Dirname) + path.sep;
  }
  return '';
}

// Converts \r\n to \n
function normalizeLf(string) {
  return string.replace(/\r\n/g, '\n');
}

module.exports = function(grunt) {
  // Internal lib.
  var uglify = require('./lib/uglify').init(grunt);

  grunt.registerMultiTask('uglify', 'Minify files with UglifyJS.', function() {
    // Merge task-specific and/or target-specific options with these defaults.
    var options = this.options({
      banner: '',
      footer: '',
      compress: {
        warnings: false
      },
      mangle: {},
      beautify: false,
      report: 'min',
      expression: false,
      maxLineLen: 32000,
      ASCIIOnly: false,
      screwIE8: true,
      quoteStyle: 0
    });

    // Process banner.
    var banner = normalizeLf(options.banner);
    var footer = normalizeLf(options.footer);
    var mapNameGenerator, mapInNameGenerator;
    var createdFiles = 0;
    var createdMaps = 0;

    // Iterate over all src-dest file pairs.
    this.files.forEach(function (f) {
      var src = f.src.filter(function (filepath) {
        // Warn on and remove invalid source files (if nonull was set).
        if (!grunt.file.exists(filepath)) {
          grunt.log.warn('Source file ' + chalk.cyan(filepath) + ' not found.');
          return false;
        }
        return true;
      });

      if (src.length === 0) {
        grunt.log.warn('Destination ' + chalk.cyan(f.dest) + ' not written because src files were empty.');
        return;
      }

      // Warn on incompatible options
      if (options.expression && (options.compress || options.mangle)) {
        grunt.log.warn('Option ' + chalk.cyan('expression') + ' not compatible with ' + chalk.cyan('compress and mangle'));
        options.compress = false;
        options.mangle = false;
      }

      // function to get the name of the sourceMap
      if (typeof options.sourceMapName === 'function') {
        mapNameGenerator = options.sourceMapName;
      }

      // function to get the name of the sourceMapIn file
      if (typeof options.sourceMapIn === 'function') {
        if (src.length !== 1) {
          grunt.fail.warn('Cannot generate `sourceMapIn` for multiple source files.');
        }
        mapInNameGenerator = options.sourceMapIn;
      }

      // dynamically create destination sourcemap name
      if (mapNameGenerator) {
        try {
          options.generatedSourceMapName = mapNameGenerator(f.dest);
        } catch (e) {
          err = new Error('SourceMap failed.');
          err.origError = e;
          grunt.fail.warn(err);
        }
      // If no name is passed append .map to the filename
      } else if (!options.sourceMapName) {
        options.generatedSourceMapName = f.dest + '.map';
      } else {
        options.generatedSourceMapName = options.sourceMapName;
      }

      // Dynamically create incoming sourcemap names
      if (mapInNameGenerator) {
        try {
          options.sourceMapIn = mapInNameGenerator(src[0]);
        } catch (e) {
          err = new Error('SourceMapInName failed.');
          err.origError = e;
          grunt.fail.warn(err);
        }
      }

      // Calculate the path from the dest file to the sourcemap for the
      // sourceMappingURL reference
      // If sourceMapUrl is defined, use this instead
      if (options.sourceMap) {
        var destToSourceMapPath, sourceMapBasename;
        if (!options.sourceMapUrl) {
          destToSourceMapPath = relativePath(f.dest, options.generatedSourceMapName);
          sourceMapBasename = path.basename(options.generatedSourceMapName);
          options.destToSourceMap = destToSourceMapPath + sourceMapBasename;
        } else {
          options.destToSourceMap = options.sourceMapUrl;
        }
      }

      // Minify files, warn and fail on error.
      var result;
      try {
        result = uglify.minify(src, f.dest, options);
      } catch (e) {
        console.log(e);
        err = new Error('Uglification failed.');
        if (e.message) {
          err.message += '\n' + e.message + '. \n';
          if (e.line) {
            err.message += 'Line ' + e.line + ' in ' + src + '\n';
          }
        }
        err.origError = e;
        grunt.log.warn('Uglifying source ' + chalk.cyan(src) + ' failed.');
        grunt.fail.warn(err);
      }

      // Concat minified source + footer
      var output = result.min + footer;

      // Only prepend banner if uglify hasn't taken care of it as part of the preamble
      if (!options.sourceMap) {
        output = banner + output;
      }

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

      // Write source map
      if (options.sourceMap) {
        grunt.file.write(options.generatedSourceMapName, result.sourceMap);
        grunt.verbose.writeln('File ' + chalk.cyan(options.generatedSourceMapName) + ' created (source map).');
        createdMaps++;
      }

      var outputSize = maxmin(result.max, output, options.report === 'gzip');
      grunt.verbose.writeln('File ' + chalk.cyan(f.dest) + ' created: ' + outputSize);

      createdFiles++;
    });

    if (createdMaps > 0) {
      grunt.log.ok(createdMaps + ' source' + grunt.util.pluralize(createdMaps, 'map/maps') + ' created.');
    }

    if (createdFiles > 0) {
      grunt.log.ok(createdFiles + ' ' + grunt.util.pluralize(this.files.length, 'file/files') + ' created.');
    } else {
      grunt.log.warn('No files created.');
    }
  });
};