Skip to content

Commit

Permalink
Updates to support @mdi/light-svg.
Browse files Browse the repository at this point in the history
  • Loading branch information
Templarian committed Dec 9, 2018
1 parent a9af4d8 commit 72aede3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 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.1.2",
"version": "0.2.0",
"description": "Util helpers for support builds.",
"main": "util.js",
"scripts": {
Expand Down
27 changes: 21 additions & 6 deletions util.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
const fs = require('fs');

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

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

exports.getMeta = (withPaths) => {
const file = fs.readFileSync(`${folder}/meta.json`, { encoding });
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}/svg/${icon.name}.svg`, { encoding });
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');
};
Expand Down

0 comments on commit 72aede3

Please sign in to comment.