2 Commits

Author SHA1 Message Date
Konstantin Vulsonov
bb2c336781 Fix svg IDs generation 2018-09-21 02:21:10 +03:00
Konstantin Vulsonov
2fc72898d3 fix IDs creation 2018-09-21 02:21:05 +03:00
3 changed files with 7 additions and 9 deletions

10
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "@vkl/svg-iconset-builder",
"version": "1.0.1",
"version": "1.0.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -42,7 +42,7 @@
"dependencies": {
"chalk": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
"dev": true,
"requires": {
@@ -496,9 +496,9 @@
"dev": true
},
"js-yaml": {
"version": "3.13.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
"version": "3.12.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz",
"integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==",
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"

View File

@@ -1,6 +1,6 @@
{
"name": "@vkl/svg-iconset-builder",
"version": "1.0.1",
"version": "1.0.2",
"description": "create iconset from separated svg icons",
"main": "./dist/app.js",
"types": "./dist/app.d.ts",

View File

@@ -30,7 +30,6 @@ export class SvgIconset {
svgClean(this.config.source, this.svgoPlugin)
.then(optimizedResponse => {
let idx = 0;
const ids = optimizedResponse.map(el => el.id);
Promise.all(optimizedResponse.map(el => el.optimized))
.then(resFiles => {
@@ -38,9 +37,8 @@ export class SvgIconset {
createWriteStream(resultFile)
.once('open', function (this: WriteStream) {
try {
const data = resFiles.map(res => res.data.replace(/<svg /, `<svg id="${ids[idx]}" `));
const data = resFiles.map((res, idx) => res.data.replace(/<svg /, `<svg id="${ids[idx]}" `));
this.write(`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">${data.join('')}</svg>`);
idx++;
this.end();
} catch (err) {
console.log('ERROR', err);