<commit_before>/**
 * Image optimization for Grunt using imgo
 *
 * @requires https://github.com/imgo/imgo
 * @author <NAME> (http://sapegin.me)
 */

/*jshint node:true */
module.exports = function(grunt) {
	'use strict';

	grunt.registerMultiTask('imgo', 'Optimize images using imgo', function() {
		this.requiresConfig([ this.name, this.target, 'files' ].join('.'));

		var done = this.async(),
			params = this.data;

		if (params.skip) {
			done();
		}

		var files = grunt.file.expandFiles(params.files);
		grunt.utils.async.forEach(files, function(file, nextFile) {
			var args = [file];
			if (params.options) {
				args.unshift(params.options);
			}
			process({
				args: args,
				done: function(data) {
					if (!data.err && data.compressed) {
						grunt.log.writeln("File '" + file + "': saved " + data.saved + " bytes " +
								"(" + Math.round(data.saved/data.before*100) + "%)");
					}
					nextFile();
				}
			});
		}, function() {
			done();
		});
	});

	function process(options) {
		return grunt.utils.spawn({
			cmd: 'imgo',
			args: options.args
		}, function(err, result, code) {
			if (!err) {
				var fields = result.split('\n')[0].split(' '),
					before = parseInt(fields[1], 10),<commit_msg>Cool green numbers in results.<commit_after>/**
 * Image optimization for Grunt using imgo
 *
 * @requires https://github.com/imgo/imgo
 * @author <NAME> (http://sapegin.me)
 */

/*jshint node:true */
module.exports = function(grunt) {
	'use strict';

	grunt.registerMultiTask('imgo', 'Optimize images using imgo', function() {
		this.requiresConfig([ this.name, this.target, 'files' ].join('.'));

		var done = this.async(),
			params = this.data;

		if (params.skip) {
			done();
		}

		var files = grunt.file.expandFiles(params.files);
		grunt.utils.async.forEach(files, function(file, nextFile) {
			var args = [file];
			if (params.options) {
				args.unshift(params.options);
			}
			process({
				args: args,
				done: function(data) {
					if (!data.err && data.compressed) {
						grunt.log.writeln("File '" + file + "': saved " + String(data.saved).green + " bytes " +
								"(" + String(Math.round(data.saved/data.before*100)).green + "%".green + ")");
					}
					nextFile();
				}
			});
		}, function() {
			done();
		});
	});

	function process(options) {
		return grunt.utils.spawn({
			cmd: 'imgo',
			args: options.args
		}, function(err, result, code) {
			if (!err) {
				var fields = result.split('\n')[0].split(' '),
					before = parseInt(fields[1], 10),
{'fraction_non_alphanumeric': 0.19304556354916066, 'fraction_numerical': 0.005595523581135092, 'mean_word_length': 3.0831973898858074, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1917168', 'n_tokens_mistral': 1041, 'n_tokens_neox': 872, 'n_words': 174}