Просмотр исходного кода

Fix bug with SVG minification+compression

Gaël Métais 10 лет назад
Родитель
Сommit
d4815e855e

+ 1 - 1
lib/tools/weightChecker/gzipCompressor.js

@@ -66,7 +66,7 @@ var GzipCompressor = function() {
                     var compressedSize = buffer.length;
 
                     if (gainIsEnough(uncompressedSize, compressedSize)) {
-                        debug('Minified file correctly gziped, was %d and is now %d bytes', uncompressedSize, compressedSize);
+                        debug('Correctly gziped the minified file, was %d and is now %d bytes', uncompressedSize, compressedSize);
 
                         entry.weightCheck.afterOptimizationAndCompression = compressedSize;
                     } else {

+ 1 - 1
lib/tools/weightChecker/imageOptimizer.js

@@ -129,7 +129,7 @@ var ImageOptimizer = function() {
                 debug('SVG lossless compression complete for %s', entry.url);
                 
                 if (gainIsEnough(fileSize, newFileSize)) {
-                    entry.weightCheck.bodyAfterOptimization = newFile;
+                    entry.weightCheck.bodyAfterOptimization = newFile.contents.toString();
                     entry.weightCheck.lossless = entry.weightCheck.optimized = newFileSize;
                     entry.weightCheck.isOptimized = false;
                     debug('Filesize is %d bytes smaller (-%d%)', fileSize - newFileSize, Math.round((fileSize - newFileSize) * 100 / fileSize));

+ 2 - 2
test/core/fileMinifierTest.js

@@ -51,7 +51,7 @@ describe('fileMinifier', function() {
         .then(function(newEntry) {
             newEntry.weightCheck.should.have.a.property('isOptimized').that.equals(false);
             newEntry.weightCheck.should.have.a.property('optimized').that.is.below(fileSize);
-            newEntry.weightCheck.should.have.a.property('bodyAfterOptimization');
+            newEntry.weightCheck.should.have.a.property('bodyAfterOptimization').that.is.a('string');
 
             done();
         })
@@ -193,7 +193,7 @@ describe('fileMinifier', function() {
         .then(function(newEntry) {
             newEntry.weightCheck.should.have.a.property('isOptimized').that.equals(false);
             newEntry.weightCheck.should.have.a.property('optimized').that.is.below(fileSize);
-            newEntry.weightCheck.should.have.a.property('bodyAfterOptimization');
+            newEntry.weightCheck.should.have.a.property('bodyAfterOptimization').that.is.a('string');
 
             done();
         })

+ 1 - 1
test/core/imageOptimizerTest.js

@@ -208,7 +208,7 @@ describe('imageOptimizer', function() {
             newEntry.weightCheck.should.have.a.property('isOptimized').that.equals(false);
             newEntry.weightCheck.should.have.a.property('lossless').that.is.below(fileSize);
             newEntry.weightCheck.should.have.a.property('optimized').that.equals(newEntry.weightCheck.lossless);
-            newEntry.weightCheck.should.have.a.property('bodyAfterOptimization');
+            newEntry.weightCheck.should.have.a.property('bodyAfterOptimization').that.is.a('string');
 
             done();
         })