Skip to content

Commit

Permalink
Fixed CLI root attributes file handling (closes svg-sprite#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkphl committed Jun 28, 2016
1 parent 5bae660 commit 580399a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@
/npm-debug.log
/coverage
/tmp
/index.js
/capture.js
/align.js
/FEATURES.md
/config.json
/dev-scripts/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 1.3.3 Bugfix release (2016-04-28)
* Fixed CLI regression bug ([#173](https://github.com/jkphl/svg-sprite/issues/173))
* Fixed CLI root attributes file handling ([#144](https://github.com/jkphl/svg-sprite/issues/144))

## 1.3.2 Feature release (2016-04-27)
* Updated dependencies
Expand Down
15 changes: 14 additions & 1 deletion bin/svg-sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ config.shape.spacing.padding = config.shape.spacing.padding.length ? config.shap
return parseFloat(dim || 0, 10);
}) : [];

if (config.svg.rootAttributes) {
try {
var JSONAttributesContent = fs.readFileSync(path.resolve(config.svg.rootAttributes));
config.svg.rootAttributes = JSON.parse(JSONAttributesContent);
} catch (e) {
console.error('[ERROR] Skipping --svg-rootattrs file due to errors ("%s")', e.message.trim());
config.svg.rootAttributes = {};
}
}

// Expand transformation options
var transform = ('' + config.shape.transform).trim();
config.shape.transform = [];
Expand Down Expand Up @@ -235,7 +245,10 @@ config.shape.transform = [];
// Remove excessive example options
for (var mode in config.mode) {
var example = mode + '-example';
if (!argv[example] && !('example' in JSONConfig.mode[mode]) && ('example' in config.mode[mode])) {
if (!argv[example]
&& (!(mode in JSONConfig.mode) || !('example' in JSONConfig.mode[mode]))
&& ('example' in config.mode[mode])
) {
delete config.mode[mode].example;
}
}
Expand Down

0 comments on commit 580399a

Please sign in to comment.