<commit_before>'use strict';
var chalk = require('chalk');
var eachAsync = require('each-async');
var prettyBytes = require('pretty-bytes');
var SVGO = require('svgo');

module.exports = function (grunt) {
	grunt.registerMultiTask('svgmin', 'Minify SVG', function () {
		var svgo = new SVGO(this.options());
		var totalSaved = 0;

		eachAsync(this.files, function (el, i, next) {
			var srcPath = el.src[0];
			var srcSvg = grunt.file.read(srcPath);

			svgo.optimize(srcSvg, function (result) {
				if (result.error) {
					return grunt.warn('Error parsing SVG: ' + result.error);
				}

				var saved = srcSvg.length - result.data.length;
				var percentage = saved / srcSvg.length * 100;
				totalSaved += saved;

				grunt.log.writeln(chalk.green('✔ ') + srcPath + chalk.gray(' (saved ' + chalk.bold(prettyBytes(saved)) + ' ' + Math.round(percentage) + '%)'));
				grunt.file.write(el.dest, result.data);
				next();
			});
		}, this.async());

		grunt.log.writeln(chalk.gray('Bytes saved in total: ' + chalk.bold(prettyBytes(totalSaved))));
	});
};<commit_msg>improve total saved output<commit_after>'use strict';
var chalk = require('chalk');
var eachAsync = require('each-async');
var prettyBytes = require('pretty-bytes');
var SVGO = require('svgo');

module.exports = function (grunt) {
	grunt.registerMultiTask('svgmin', 'Minify SVG', function () {
		var svgo = new SVGO(this.options());
		var totalSaved = 0;

		eachAsync(this.files, function (el, i, next) {
			var srcPath = el.src[0];
			var srcSvg = grunt.file.read(srcPath);

			svgo.optimize(srcSvg, function (result) {
				if (result.error) {
					return grunt.warn('Error parsing SVG: ' + result.error);
				}

				var saved = srcSvg.length - result.data.length;
				var percentage = saved / srcSvg.length * 100;
				totalSaved += saved;

				grunt.log.writeln(chalk.green('✔ ') + srcPath + chalk.gray(' (saved ' + chalk.bold(prettyBytes(saved)) + ' ' + Math.round(percentage) + '%)'));
				grunt.file.write(el.dest, result.data);
				next();
			});
		}, this.async());

		grunt.log.writeln('Total saved: ' + chalk.green(prettyBytes(totalSaved)));
	});
};
{'fraction_non_alphanumeric': 0.17757889778615168, 'fraction_numerical': 0.004710315591144607, 'mean_word_length': 3.905311778290993, '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': '2173544', 'n_tokens_mistral': 846, 'n_tokens_neox': 731, 'n_words': 151}