提交 7389bcdd 编写于 作者: B Bogdan Chadkin

Override default floatPrecision with global

Ref https://github.com/svg/svgo/issues/1426

Previously extendDefaultPlugins incorrectly overrided global
floatPrecision.
上级 d08815c1
......@@ -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, {});
......
......@@ -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', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册