Skip to content

Commit

Permalink
Publish @mdi/util
Browse files Browse the repository at this point in the history
  • Loading branch information
Templarian committed Apr 13, 2018
1 parent ef988db commit b267bfc
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@mdi/util",
"version": "0.1.0",
"description": "Util helpers for support builds.",
"main": "util.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Templarian/MaterialDesign-Util.git"
},
"author": "Austin Andrews (@Templarian)",
"license": "MIT",
"bugs": {
"url": "https://github.com/Templarian/MaterialDesign-Util/issues"
},
"homepage": "https://github.com/Templarian/MaterialDesign-Util#readme"
}
34 changes: 34 additions & 0 deletions util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const fs = require('fs');

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

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

exports.getMeta = (withPaths) => {
const file = fs.readFileSync(`${folder}/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 });
icon.path = svg.match(/d="([^"]+)"/)[1];
});
}
return meta;
};

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

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

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

0 comments on commit b267bfc

Please sign in to comment.