Skip to content

Commit

Permalink
Merge 83a0912 into 945bb2c
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Mar 24, 2022
2 parents 945bb2c + 83a0912 commit d7f38d4
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
3 changes: 2 additions & 1 deletion bin/svg-sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
const fs = require('fs');
const path = require('path');
const _ = require('lodash');
const merge = require('lodash.merge');
const File = require('vinyl');
const yaml = require('js-yaml');
const glob = require('glob');
Expand Down Expand Up @@ -176,7 +177,7 @@ if (argv.config) {
}
}

_.merge(config, externalConfig);
merge(config, externalConfig);
} catch (error) {
console.error('[ERROR] Skipping --config file due to errors ("%s")', error.message.trim());
}
Expand Down
3 changes: 2 additions & 1 deletion lib/svg-sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const events = require('events');
const os = require('os');
const { format } = require('util');
const _ = require('lodash');
const merge = require('lodash.merge');
const File = require('vinyl');
const async = require('async');
const pretty = require('prettysize');
Expand Down Expand Up @@ -202,7 +203,7 @@ SVGSpriter.prototype.compile = function(config, cb) {
const _config = isPlainObject(config) ?
// eslint-disable-next-line unicorn/no-array-callback-reference
this.config.filter(config) :
_.merge({}, this.config.mode);
merge({}, this.config.mode);
let _cb;

if (isFunction(cb)) {
Expand Down
6 changes: 3 additions & 3 deletions lib/svg-sprite/layouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license MIT https://github.com/svg-sprite/svg-sprite/blob/main/LICENSE
*/

const _ = require('lodash');
const merge = require('lodash.merge');

const defaultConfig = {
css: {
Expand Down Expand Up @@ -136,8 +136,8 @@ module.exports = class SVGSpriteLayouter {
layout(files, key, mode, cb) {
this._spriter.info('Laying out «%s» sprite («%s» mode)', key, mode);
const SVGSpriteLayout = require(`./mode/${mode}`);
const config = _.merge(_.merge(_.merge({}, defaultConfig[mode]), { svg: this._spriter.config.svg }), this.config[key] || {});
const data = _.merge(_.merge(_.merge({}, this._commonData), this._spriter.config.variables), config.variables);
const config = merge(merge(merge({}, defaultConfig[mode]), { svg: this._spriter.config.svg }), this.config[key] || {});
const data = merge(merge(merge({}, this._commonData), this._spriter.config.variables), config.variables);
const sprite = new SVGSpriteLayout(this._spriter, config, data, key);
files[key] = {};
sprite.layout(files[key], cb);
Expand Down
4 changes: 2 additions & 2 deletions lib/svg-sprite/mode/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const fs = require('fs');
const crypto = require('crypto');
const path = require('path');
const process = require('process');
const _ = require('lodash');
const merge = require('lodash.merge');
const async = require('async');
const mustache = require('mustache');
const File = require('vinyl');
Expand Down Expand Up @@ -89,7 +89,7 @@ function SVGSpriteBase(spriter, config, data, key) {
}

// Refine the base data
this.data = _.merge(this.data, this._initData({
this.data = merge(this.data, this._initData({
padding: this._spriter.config.shape.spacing.padding,
sprite: path.relative(this._cssDest, this.config.sprite).split(path.sep).join('/')
}));
Expand Down
6 changes: 3 additions & 3 deletions lib/svg-sprite/shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

const path = require('path');
const { format } = require('util');
const _ = require('lodash');
const merge = require('lodash.merge');
const { DOMParser, XMLSerializer } = require('@xmldom/xmldom');
const xpath = require('xpath');
const cssom = require('cssom');
Expand Down Expand Up @@ -147,7 +147,7 @@ function SVGShape(file, spriter) {
this.spriter = spriter;
this.svg = { current: this.source.contents.toString(), ready: null };
this.name = path.basename(this.source.path);
this.config = _.merge(_.merge({}, defaultConfig), this.spriter.config.shape || {});
this.config = merge(merge({}, defaultConfig), this.spriter.config.shape || {});

if (!isFunction(this.config.id.generator)) {
this.config.id.generator = createIdGenerator(isString(this.config.id.generator) ? this.config.id.generator + (this.config.id.generator.includes('%s') ? '' : '%s') : '%s');
Expand Down Expand Up @@ -896,7 +896,7 @@ SVGShape.prototype.distribute = function() {

// Run through all remaining alignments
alignments.forEach(alignment => {
const copy = _.merge(new SVGShape(this.source, this.spriter), this);
const copy = merge(new SVGShape(this.source, this.spriter), this);
copy.base = format(alignment[0], base);
copy.id = copy.base + (this.state ? this.config.id.pseudo + this.state : '');
copy.align = alignment[1];
Expand Down
4 changes: 2 additions & 2 deletions lib/svg-sprite/transform/svgo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* @license MIT https://github.com/svg-sprite/svg-sprite/blob/main/LICENSE
*/

const merge = require('lodash.merge');
const svgo = require('svgo');
const _ = require('lodash');
const pretty = require('prettysize');

/**
Expand All @@ -24,7 +24,7 @@ const pretty = require('prettysize');
module.exports = function(shape, config, spriter, cb) {
const defaultPluginsConfig = ['preset-default'];

config = _.merge({}, config);
config = merge({}, config);
config.plugins = 'plugins' in config ? config.plugins : defaultPluginsConfig;

config.plugins.push({
Expand Down
7 changes: 3 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"image-size": "^1.0.1",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"lodash.merge": "^4.6.2",
"mustache": "^4.2.0",
"prettysize": "^2.0.0",
"svgo": "^2.8.0",
Expand Down

0 comments on commit d7f38d4

Please sign in to comment.