Skip to content

Commit

Permalink
Fixes #166 - output more info in CLI's debug mode.
Browse files Browse the repository at this point in the history
* Show efficiency with up to two decimal places.
  • Loading branch information
GoalSmashers committed Nov 4, 2013
1 parent 1b84e61 commit d7a2489
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions bin/cleancss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 10 additions & 6 deletions test/binary-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit d7a2489

Please sign in to comment.