Skip to content

Commit

Permalink
Merge pull request #57 from raido/update-deps
Browse files Browse the repository at this point in the history
Update SVGO to ~1.0.5
  • Loading branch information
raido authored Jul 26, 2018
2 parents 14c8bc5 + 99d7eb9 commit a6250dd
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 48 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"merge": "^1.2.0",
"mkdirp": "^0.5.1",
"promise-map-series": "^0.2.1",
"rsvp": "^3.2.1",
"svgo": "^0.6.3",
"svgo": "~1.0.5",
"walk-sync": "^0.3.1"
},
"devDependencies": {
Expand Down
14 changes: 2 additions & 12 deletions svg-optimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var walkSync = require('walk-sync');
var mkdirp = require('mkdirp');
var path = require('path');
var SVGO = require('svgo');
var RSVP = require('rsvp');
var fs = require('fs');


Expand Down Expand Up @@ -40,17 +39,8 @@ SVGOptimizer.prototype.build = function() {
var destPath = path.join(destDir, relativePath);
var rawSVG = fs.readFileSync(srcPath, { encoding: 'utf8' });

return new RSVP.Promise(function(resolve, reject) {
svgo.optimize(rawSVG, function(result) {
if (result.error) {
var error = new Error(result.error);
error.file = relativePath;
return reject(error);
}

fs.writeFileSync(destPath, result.data, { encoding: 'utf8'});
resolve();
});
return svgo.optimize(rawSVG).then(function(result) {
fs.writeFileSync(destPath, result.data, { encoding: 'utf8' });
});
}
});
Expand Down
Loading

0 comments on commit a6250dd

Please sign in to comment.