<commit_before>var through = require('through2'),
	cheerio = require('cheerio'),
	uglify = require('uglify-js'),
	gutil = require('gulp-util');

const PLUGIN_NAME = 'gulp-uglify-inline';

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

	opt.fromString = true;

	function minimize ( file, encoding, callback )
	{
		if (file.isNull())
		{
			return callback(null, file);
		}

		if (file.isStream())
		{
			return callback(new gutil.PluginError('gulp-uglify-inline', 'doesn\'t support Streams'));
		}

		var $ = cheerio.load(file.contents.toString());

		var has_done_nothing = true;

		$('script').each(function ( )
		{
			var $this = $(this),
				script_orig = $this.text().trim();

			if (script_orig !== '')
			{
				var script_min = uglify.minify(script_orig, opt);

				$this.text(script_min.code);

				has_done_nothing = false;
			}
		});

		if (!has_done_nothing) file.contents = new Buffer($.html());

		callback(null, file);
	}

	return through.obj(minimize);
}
<commit_msg>Implementation<commit_after>var through = require('through2'),
	cheerio = require('cheerio'),
	uglifyjs = require('uglify-js'),
	cleancss = require('clean-css'),
	gutil = require('gulp-util');

const PLUGIN_NAME = 'gulp-minify-inline';

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

	function minify ( file, encoding, callback )
	{
		if (file.isNull())
		{
			return callback(null, file);
		}

		if (file.isStream())
		{
			return callback(new gutil.PluginError('gulp-minify-inline', 'doesn\'t support Streams'));
		}

		var $ = cheerio.load(file.contents.toString());

		var has_done_nothing = true;

		if (opt.js !== false) $('script').each(function ( )
		{
			if (!opt.js) opt.js = {};

			opt.js.fromString = true;

			var $this = $(this),
				script_orig = $this.text().trim();

			if (script_orig !== '')
			{
				var script_min = uglifyjs.minify(script_orig, opt.js);

				$this.text(script_min.code);

				has_done_nothing = false;
			}
		});

		if (opt.css !== false) $('style').each(function ( )
		{
			var $this = $(this),
				style_orig = $this.text().trim();

			if (style_orig !== '')
			{
				var style_min = new cleancss(opt.css).minify(style_orig);

				$this.text(style_min);

				has_done_nothing = false;
			}
		});

		if (!has_done_nothing) file.contents = new Buffer($.html());

		callback(null, file);
	}

	return through.obj(minify);
}
{'fraction_non_alphanumeric': 0.1807382265591854, 'fraction_numerical': 0.0008485362749257531, 'mean_word_length': 3.508604206500956, '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': '578228', 'n_tokens_mistral': 987, 'n_tokens_neox': 844, 'n_words': 158}