Skip to content

Commit

Permalink
Override default floatPrecision with global
Browse files Browse the repository at this point in the history
Ref #1426

Previously extendDefaultPlugins incorrectly overrided global
floatPrecision.
  • Loading branch information
TrySound committed Mar 22, 2021
1 parent d08815c commit 7389bcd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/svgo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ exports.defaultPlugins = defaultPlugins;
const extendDefaultPlugins = (plugins) => {
const extendedPlugins = pluginsOrder.map((name) => ({
name,
...pluginsMap[name],
active: pluginsMap[name].active,
}));
for (const plugin of plugins) {
const resolvedPlugin = resolvePluginConfig(plugin, {});
Expand Down
12 changes: 12 additions & 0 deletions test/config/_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,18 @@ describe('config', function () {
'customPlugin'
);
});
it('should pass global floatPrecision when plugin one not specified', () => {
const convertPathDataPlugin = resolvePluginConfig(
extendedPlugins.find((item) => item.name === 'convertPathData'),
{ floatPrecision: 1 }
);
const convertTransformPlugin = resolvePluginConfig(
extendedPlugins.find((item) => item.name === 'convertTransform'),
{}
);
expect(convertPathDataPlugin.params.floatPrecision).to.equal(1);
expect(convertTransformPlugin.params.floatPrecision).to.equal(3);
});
});

describe('config', () => {
Expand Down

0 comments on commit 7389bcd

Please sign in to comment.