Skip to content

Commit

Permalink
Fix parsing of d attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Templarian committed Feb 26, 2019
1 parent 72aede3 commit 145fd84
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mdi/util",
"version": "0.2.0",
"version": "0.3.0",
"description": "Util helpers for support builds.",
"main": "util.js",
"scripts": {
Expand Down
106 changes: 53 additions & 53 deletions util.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
const fs = require('fs');

const encoding = "utf8";
const folder = `${__dirname}/../`;
const packageName = 'svg'

const getVersion = (overridePackageName) => {
const pName = overridePackageName || packageName;
const file = fs.readFileSync(`${folder}${pName}/package.json`, { encoding });
return JSON.parse(file).version;
};

const getMeta = (withPaths, overridePackageName) => {
const pName = overridePackageName || packageName;
const file = fs.readFileSync(`${folder}${pName}/meta.json`, { encoding });
const meta = JSON.parse(file);
if (withPaths) {
const total = meta.length;
meta.forEach((icon, i) => {
const svg = fs.readFileSync(`${folder}${pName}/svg/${icon.name}.svg`, { encoding });
icon.path = svg.match(/d="([^"]+)"/)[1];
});
}
return meta;
};

exports.getVersionLight = () => {
return getVersion('light-svg');
}

exports.getMetaLight = (withPaths) => {
return getMeta(withPaths, 'light-svg');
}

exports.getVersion = getVersion;

exports.getMeta = getMeta;

exports.closePath = (path) => {
return path.replace(/(\d)M/g, '$1ZM');
};

exports.write = (file, data) => {
fs.writeFileSync(file, data);
};

exports.read = (file) => {
fs.readFileSync(file);
};

exports.exists = (file) => {
return fs.exists(file);
};
const fs = require('fs');

const encoding = "utf8";
const folder = `${__dirname}/../`;
const packageName = 'svg'

const getVersion = (overridePackageName) => {
const pName = overridePackageName || packageName;
const file = fs.readFileSync(`${folder}${pName}/package.json`, { encoding });
return JSON.parse(file).version;
};

const getMeta = (withPaths, overridePackageName) => {
const pName = overridePackageName || packageName;
const file = fs.readFileSync(`${folder}${pName}/meta.json`, { encoding });
const meta = JSON.parse(file);
if (withPaths) {
const total = meta.length;
meta.forEach((icon, i) => {
const svg = fs.readFileSync(`${folder}${pName}/svg/${icon.name}.svg`, { encoding });
icon.path = svg.match(/ d="([^"]+)"/)[1];
});
}
return meta;
};

exports.getVersionLight = () => {
return getVersion('light-svg');
}

exports.getMetaLight = (withPaths) => {
return getMeta(withPaths, 'light-svg');
}

exports.getVersion = getVersion;

exports.getMeta = getMeta;

exports.closePath = (path) => {
return path.replace(/(\d)M/g, '$1ZM');
};

exports.write = (file, data) => {
fs.writeFileSync(file, data);
};

exports.read = (file) => {
fs.readFileSync(file);
};

exports.exists = (file) => {
return fs.exists(file);
};

0 comments on commit 145fd84

Please sign in to comment.