Skip to content

Commit

Permalink
Added support for mode shorthand definitions in CLI mode (closes #183)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkphl committed Aug 12, 2016
1 parent 09a66cd commit fbc3186
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## 1.3.4 Bugfix release (unreleased)
## 1.3.4 Bugfix release (2016-08-12)
* Updated dependencies
* Extended the ID generator callback signature ([#176](https://github.com/jkphl/svg-sprite/issues/176))
* Improved usage pattern example ([#177](https://github.com/jkphl/svg-sprite/issues/177))
* Added support for mode shorthand definitions in CLI mode ([#183](https://github.com/jkphl/svg-sprite/issues/183))

## 1.3.3 Bugfix release (2016-04-28)
* Fixed CLI regression bug ([#173](https://github.com/jkphl/svg-sprite/issues/173))
Expand Down
17 changes: 16 additions & 1 deletion bin/svg-sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,28 @@ if (argv['config']) {
delete argv['config'];
delete argv['C'];
var JSONConfigContent = fs.readFileSync(path.resolve(file));
mergeConfig(JSON.parse(JSONConfigContent), config);
var externalConfig = JSON.parse(JSONConfigContent);

// Make a clone of initial config for options removal checks
JSONConfig = JSON.parse(JSONConfigContent);
if (!('mode' in JSONConfig)) {
JSONConfig['mode'] = {};
}

// Expand shorthand mode definitions
if (('mode' in externalConfig) && _.isObject(externalConfig.mode)) {
for (var emode in externalConfig.mode) {
if (externalConfig.mode[emode] === true) {
externalConfig.mode[emode] = JSONConfig.mode[emode] = {
render: {
css: true
}
};
}
}
}

mergeConfig(externalConfig, config);
} catch (e) {
console.error('[ERROR] Skipping --config file due to errors ("%s")', e.message.trim());
}
Expand Down

0 comments on commit fbc3186

Please sign in to comment.