Skip to content

Commit

Permalink
publishing version 0.0.4, adding declaration file
Browse files Browse the repository at this point in the history
  • Loading branch information
cadgerfeast committed Oct 9, 2019
1 parent f1d671b commit 469dc9a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
21 changes: 20 additions & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ const distPath = path.resolve(__dirname, 'dist');

const icons = require('./icons.json');

let declaration = `declare interface PixelSvgData {
svg: string;
}
declare interface PixelIcon {
tags: string[];
data: PixelSvgData
}
declare module 'icons.json' {
const value: { [icon in PixelIconList]: PixelIcon; };
export default value;
}`;

function rimraf (folder) {
if (fs.existsSync(folder)) {
fs.readdirSync(folder).forEach((entry) => {
Expand Down Expand Up @@ -116,16 +130,21 @@ const build = async function () {
iconList.splice(i, 1);
}
}
declaration += '\n\ndeclare enum PixelIconList {';
for (const icon in finalIconList) {
const { svgIcon, svgData } = await createIcon(`${icon}.png`, iconsSvgPath, icons150Path, icons1500Path);
finalIconList[icon].svg = svgData;
finalIconList[icon].data = svgData;
svgFiles.push(svgIcon);
declaration += `\n\t'${icon}' = '${icon}',`;
}
declaration = declaration.slice(0, -1);
declaration += '\n}';
// Building icon list
if (fs.existsSync(distPath)) {
rimraf(distPath);
}
fs.mkdirSync(distPath);
fs.writeFileSync(path.resolve(distPath, 'icons.d.ts'), declaration);
fs.writeFileSync(path.resolve(distPath, 'icons.json'), JSON.stringify(finalIconList, null, 2));
// Building docs
generateList(finalIconList);
Expand Down
Binary file modified fonts/PixelIcons.eot
Binary file not shown.
Binary file modified fonts/PixelIcons.ttf
Binary file not shown.
Binary file modified fonts/PixelIcons.woff
Binary file not shown.
Binary file modified fonts/PixelIcons.woff2
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@pixel/icons",
"version": "0.0.3",
"version": "0.0.4",
"main": "dist/icons.json",
"types": "dist/icons.d.ts",
"scripts": {
"build": "node build.js",
"lint": "eslint .",
Expand All @@ -20,6 +21,7 @@
"url": "git+https://github.com/cadgerfeast/pixel-icons.git"
},
"files": [
"dist",
"fonts",
"png-15",
"png-150",
Expand Down

0 comments on commit 469dc9a

Please sign in to comment.