Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

icon-maker

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

icon-maker - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

87

index.js

@@ -7,3 +7,4 @@ const path = require('path');

constructor({
files = ['ttf', 'woff', 'eot', 'svg']
files = ['ttf', 'woff', 'eot', 'svg'],
fontFamily = 'default'
} = {}) {

@@ -19,11 +20,8 @@ if (files === undefined || !Array.isArray(files)) {

}
this._fontFamily = fontFamily;
this._files = files;
this._fonts = {};
this._svgs = [];
}
addSvg(svgPath, fontFamily = 'default') {
const fonts = this._fonts;
if (fonts[fontFamily] === undefined) {
fonts[fontFamily] = [];
}
fonts[fontFamily].push(svgPath);
this._svgs.push(svgPath);
}

@@ -36,50 +34,41 @@ run(cb) {

const files = this._files;
const fontsPromises = Object.keys(this._fonts).map(fontFamily => new Promise((resolve, reject) => {
const svgPaths = this._fonts[fontFamily];
const svgPaths = this._svgs;
const fontFamily = this._fontFamily;
let fontmin = new Fontmin().src(svgPaths).use(Fontmin.svgs2ttf(fontFamily));
if (files.indexOf('eot') !== -1) {
fontmin = fontmin.use(Fontmin.ttf2eot({ fontFamily }));
let fontmin = new Fontmin().src(svgPaths).use(Fontmin.svgs2ttf(fontFamily));
if (files.indexOf('eot') !== -1) {
fontmin = fontmin.use(Fontmin.ttf2eot({ fontFamily }));
}
if (files.indexOf('woff') !== -1) {
fontmin = fontmin.use(Fontmin.ttf2woff({ fontFamily }));
}
if (files.indexOf('svg') !== -1) {
fontmin = fontmin.use(Fontmin.ttf2svg({ fontFamily }));
}
fontmin.use(Fontmin.css({
fontFamily,
iconPrefix: fontFamily,
glyph: true
}));
fontmin.run((err, fontFiles) => {
if (err) {
cb(err);
}
if (files.indexOf('woff') !== -1) {
fontmin = fontmin.use(Fontmin.ttf2woff({ fontFamily }));
}
if (files.indexOf('svg') !== -1) {
fontmin = fontmin.use(Fontmin.ttf2svg({ fontFamily }));
}
fontmin.use(Fontmin.css({
fontFamily,
iconPrefix: fontFamily,
glyph: true
}));
cb(undefined, fontFiles.reduce((obj, fontFile) => {
if (path.extname(fontFile.path) === '.css') {
const cssContents = replaceCssContents(fontFile.contents.toString(), files);
fontmin.run((err, fontFiles) => {
if (err) {
reject(err);
return Object.assign(obj, {
css: cssContents
});
} else {
return Object.assign(obj, {
fontFiles: (obj.fontFiles || [])
.concat(fontFile)
});
}
resolve(
fontFiles.reduce((obj, fontFile) => {
if (path.extname(fontFile.path) === '.css') {
const cssContents = replaceCssContents(fontFile.contents.toString(), files);
return Object.assign(obj, {
css: cssContents
});
} else {
return Object.assign(obj, {
fontFiles: (obj.fontFiles || [])
.concat(fontFile)
});
}
}, { fontFamily })
);
});
}));
Promise.all(fontsPromises).then(fonts => {
cb(undefined, fonts);
}, err => {
cb(err);
}, { fontFamily }));
});
}
};
{
"name": "icon-maker",
"version": "0.1.0",
"version": "0.2.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -0,0 +0,0 @@ module.exports = (cssContents, fileExtensions) => {

@@ -7,5 +7,5 @@ const path = require('path');

iconMaker.addSvg(path.join(__dirname, 'svg', 'yin-yan.svg'));
iconMaker.addSvg(path.join(__dirname, 'svg', 'yin-yan.svg'), 'blaEE');
iconMaker.run((err, fonts) => {
console.log(fonts[0].fontFiles[0].path);
iconMaker.addSvg(path.join(__dirname, 'svg', 'yin-yan.svg'));
iconMaker.run((err, font) => {
console.log(font.fontFiles[0].path);
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc