From: GoalSmashers Date: Mon, 4 Nov 2013 08:01:52 +0000 (+0100) Subject: Fixes #166 - output more info in CLI's `debug` mode. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=d7a24893fde79f8139be880e2f8493da809cf12d;p=clean-css.git Fixes #166 - output more info in CLI's `debug` mode. * Show efficiency with up to two decimal places. --- diff --git a/History.md b/History.md index 775cf681..2ecc4cc3 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,7 @@ * Fixed issue [#157](https://github.com/GoalSmashers/clean-css/issues/157) - gets rid of `removeEmpty` option. * Fixed issue [#159](https://github.com/GoalSmashers/clean-css/issues/159) - escaped quotes inside content. * Fixed issue [#162](https://github.com/GoalSmashers/clean-css/issues/162) - strip quotes from Base64 encoded URLs. +* Fixed issue [#166](https://github.com/GoalSmashers/clean-css/issues/166) - `debug` formatting in CLI * Fixed issue [#167](https://github.com/GoalSmashers/clean-css/issues/167) - `background:transparent` minification. * Adds CSS tokenizer which will make it possible to optimize content by reordering and/or merging selectors. * Adds basic optimizer removing duplicate selectors from a list. diff --git a/bin/cleancss b/bin/cleancss index 1ba077b9..c136bc43 100755 --- a/bin/cleancss +++ b/bin/cleancss @@ -107,8 +107,10 @@ function minify(data) { var minified = minifier.minify(data); if (cleanOptions.debug) { - console.error('Minification time: %dms', minifier.stats.timeSpent); - console.error('Compression efficiency: %d%', ~~(minifier.stats.efficiency * 100)); + console.error('Original: %d bytes', minifier.stats.originalSize); + console.error('Minified: %d bytes', minifier.stats.minifiedSize); + console.error('Efficiency: %d%', ~~(minifier.stats.efficiency * 10000) / 100.0); + console.error('Time spent: %dms', minifier.stats.timeSpent); } return minified; diff --git a/test/binary-test.js b/test/binary-test.js index 0a5017ec..87c88cb4 100644 --- a/test/binary-test.js +++ b/test/binary-test.js @@ -79,20 +79,24 @@ exports.commandsSuite = vows.describe('binary commands').addBatch({ assert.equal(stdout, 'a{display:block}'); } }), - 'piped with debug info': pipedContext('a{color:#f00}', '-d', { + 'piped with debug info': pipedContext('a{color: #f00;}', '-d', { 'should output content to stdout and debug info to stderr': function(error, stdout, stderr) { assert.equal(stdout, 'a{color:red}'); assert.notEqual(stderr, ''); - assert.include(stderr, 'Minification time:'); - assert.include(stderr, 'Compression efficiency:'); + assert.include(stderr, 'Time spent:'); + assert.include(stderr, 'Original: 16 bytes'); + assert.include(stderr, 'Minified: 12 bytes'); + assert.include(stderr, 'Efficiency: 25%'); } }), - 'to output file with debug info': pipedContext('a{color:#f00}', '-d -o debug.css', { + 'to output file with debug info': pipedContext('a{color: #f00;}', '-d -o debug.css', { 'should output nothing to stdout and debug info to stderr': function(error, stdout, stderr) { assert.equal(stdout, ''); assert.notEqual(stderr, ''); - assert.include(stderr, 'Minification time:'); - assert.include(stderr, 'Compression efficiency:'); + assert.include(stderr, 'Time spent:'); + assert.include(stderr, 'Original: 16 bytes'); + assert.include(stderr, 'Minified: 12 bytes'); + assert.include(stderr, 'Efficiency: 25%'); }, 'should output content to file': function() { var minimized = readFile('debug.css');