Socket
Socket
Sign inDemoInstall

svgicons2svgfont

Package Overview
Dependencies
Maintainers
5
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svgicons2svgfont - npm Package Compare versions

Comparing version 14.0.0 to 14.0.1

5

bin/svgicons2svgfont.js

@@ -8,3 +8,2 @@ #! /usr/bin/env node

import { glob } from 'glob';
import { SVGIcons2SVGFontStream } from '../dist/index.js';

@@ -75,3 +74,3 @@ import { SVGIconsDirStream } from '../dist/iconsdir.js';

if (!program.args.length) {
console.error('No icons specified!'); // eslint-disable-line
console.error('No icons specified!');
process.exit(1);

@@ -86,3 +85,2 @@ }

prependUnicode: options.prependUnicode,
log: options.v ? console.log : function () { }, // eslint-disable-line
})

@@ -103,5 +101,4 @@ .pipe(

metadata: options.metadata,
log: options.v ? console.log : function () { }, // eslint-disable-line
})
)
.pipe(options.output ? createWriteStream(options.output) : process.stdout);

@@ -0,1 +1,10 @@

## [14.0.1](https://github.com/nfroidure/svgicons2svgfont/compare/v14.0.0...v14.0.1) (2024-08-01)
### Bug Fixes
* **bin:** fix script mod eoutput to avoid logging unecessary data ([2ef67d3](https://github.com/nfroidure/svgicons2svgfont/commit/2ef67d320ef31e01d4ad4eab996adf9eb1386358))
# [14.0.0](https://github.com/nfroidure/svgicons2svgfont/compare/v13.0.0...v14.0.0) (2024-07-30)

@@ -2,0 +11,0 @@

4

dist/iconsdir.js

@@ -5,2 +5,4 @@ import { Readable } from 'node:stream';

import { getMetadataService, } from './metadata.js';
import debug from 'debug';
const warn = debug('svgicons2svgfont');
class SVGIconsDirStream extends Readable {

@@ -37,3 +39,3 @@ _options;

if (metadata.renamed) {
console.log('➕ - Saved codepoint: ' +
warn('➕ - Saved codepoint: ' +
'u' +

@@ -40,0 +42,0 @@ metadata.unicode[0]

@@ -8,2 +8,4 @@ import { ucs2 } from 'punycode';

import { YError } from 'yerror';
import debug from 'debug';
const warn = debug('svgicons2svgfont');
export { fileSorter } from './filesorter.js';

@@ -185,3 +187,3 @@ export * from './iconsdir.js';

else {
console.log(`Glyph "${glyph.name}" has no width attribute, using current glyph horizontal bounds.`);
warn(`⚠️ - Glyph "${glyph.name}" has no width attribute, using current glyph horizontal bounds.`);
glyph.defaultWidth = true;

@@ -193,3 +195,3 @@ }

else {
console.log(`Glyph "${glyph.name}" has no height attribute, using current glyph vertical bounds.`);
warn(`⚠️ - Glyph "${glyph.name}" has no height attribute, using current glyph vertical bounds.`);
glyph.defaultHeight = true;

@@ -201,3 +203,3 @@ }

// Clipping path unsupported
console.log(`Found a clipPath element in the icon "${glyph.name}" the result may be different than expected.`);
warn(`🤷 - Found a clipPath element in the icon "${glyph.name}" the result may be different than expected.`);
}

@@ -208,7 +210,7 @@ else if ('rect' === tag.name && 'none' !== tag.attributes.fill) {

else if ('line' === tag.name && 'none' !== tag.attributes.fill) {
console.log(`Found a line element in the icon "${glyph.name}" the result could be different than expected.`);
warn(`🤷 - Found a line element in the icon "${glyph.name}" the result could be different than expected.`);
glyph.paths.push(applyTransform(svgShapesToPath.lineToPath(tag.attributes)));
}
else if ('polyline' === tag.name && 'none' !== tag.attributes.fill) {
console.log(`Found a polyline element in the icon "${glyph.name}" the result could be different than expected.`);
warn(`🤷 - Found a polyline element in the icon "${glyph.name}" the result could be different than expected.`);
glyph.paths.push(applyTransform(svgShapesToPath.polylineToPath(tag.attributes)));

@@ -291,7 +293,7 @@ }

: this.glyphs[0].height)) {
console.log('The provided icons do not have the same heights. This could lead' +
warn('🤷 - The provided icons do not have the same heights. This could lead' +
' to unexpected results. Using the normalize option may help.');
}
if (1000 > fontHeight) {
console.log('A fontHeight of at least than 1000 is recommended, otherwise ' +
warn('🤷 - A fontHeight of at least than 1000 is recommended, otherwise ' +
'further steps (rounding in svg2ttf) could lead to ugly results.' +

@@ -391,3 +393,3 @@ ' Use the fontHeight option to scale icons.');

this.push(' </font>\n' + '</defs>\n' + '</svg>\n');
console.log('Font created');
warn('✅ - Font created');
if ('function' === typeof this._options.callback) {

@@ -394,0 +396,0 @@ this._options.callback(this.glyphs);

@@ -7,3 +7,3 @@ import { describe, test, expect } from '@jest/globals';

try {
await mkdir(join('src', 'tests', 'results'));
await mkdir(join('fixtures', 'results'));
}

@@ -15,8 +15,9 @@ catch (err) {

test('should work for simple SVG', async () => {
const command = `${'node' + ' '}${join('bin', 'svgicons2svgfont.js')} -o ${join('src', 'tests', 'results', 'originalicons-cli.svg')} -s 0xE001` +
` ${join('src', 'tests', 'fixtures', 'originalicons', '*.svg')}`;
const command = `${'node' + ' '}${join('bin', 'svgicons2svgfont.js')} -o ${join('fixtures', 'results', 'originalicons-cli.svg')} -s 0xE001` + ` ${join('fixtures', 'icons', 'originalicons', '*.svg')}`;
await promisify(exec)(command);
expect(await readFile(join('src', 'tests', 'results', 'originalicons-cli.svg'), {
expect(await readFile(join('fixtures', 'results', 'originalicons-cli.svg'), {
encoding: 'utf8',
})).toEqual(await readFile(join('src', 'tests', 'expected', 'originalicons-cli.svg'), { encoding: 'utf8' }));
})).toEqual(await readFile(join('fixtures', 'expected', 'originalicons-cli.svg'), {
encoding: 'utf8',
}));
});

@@ -28,25 +29,25 @@ test('should work for more than 32 SVG icons', async () => {

' -o ' +
join('src', 'tests', 'results', 'lotoficons-cli.svg') +
join('fixtures', 'results', 'lotoficons-cli.svg') +
' -s 0xE001' +
' -r 1e4' +
' ' +
join('src', 'tests', 'fixtures', 'cleanicons', '*.svg') +
join('fixtures', 'icons', 'cleanicons', '*.svg') +
' ' +
join('src', 'tests', 'fixtures', 'hiddenpathesicons', '*.svg') +
join('fixtures', 'icons', 'hiddenpathesicons', '*.svg') +
' ' +
join('src', 'tests', 'fixtures', 'multipathicons', 'kikoolol.svg') +
join('fixtures', 'icons', 'multipathicons', 'kikoolol.svg') +
' ' +
join('src', 'tests', 'fixtures', 'originalicons', '*.svg') +
join('fixtures', 'icons', 'originalicons', '*.svg') +
' ' +
join('src', 'tests', 'fixtures', 'realicons', '*.svg') +
join('fixtures', 'icons', 'realicons', '*.svg') +
' ' +
join('src', 'tests', 'fixtures', 'roundedcorners', '*.svg') +
join('fixtures', 'icons', 'roundedcorners', '*.svg') +
' ' +
join('src', 'tests', 'fixtures', 'shapeicons', '*.svg') +
join('fixtures', 'icons', 'shapeicons', '*.svg') +
' ' +
join('src', 'tests', 'fixtures', 'tocentericons', '*.svg');
join('fixtures', 'icons', 'tocentericons', '*.svg');
await promisify(exec)(command);
expect(await readFile(join('src', 'tests', 'results', 'lotoficons-cli.svg'), {
expect(await readFile(join('fixtures', 'results', 'lotoficons-cli.svg'), {
encoding: 'utf8',
})).toEqual(await readFile(join('src', 'tests', 'expected', 'lotoficons-cli.svg'), {
})).toEqual(await readFile(join('fixtures', 'expected', 'lotoficons-cli.svg'), {
encoding: 'utf8',

@@ -57,7 +58,9 @@ }));

test('should work', async () => {
const command = `${'node' + ' '}${join('bin', 'svgicons2svgfont.js')} -o ${join('src', 'tests', 'results', 'nestedicons-cli.svg')} ${join('src', 'tests', 'fixtures', 'nestedicons', '*.svg')}`;
const command = `${'node' + ' '}${join('bin', 'svgicons2svgfont.js')} -o ${join('fixtures', 'results', 'nestedicons-cli.svg')} ${join('fixtures', 'icons', 'nestedicons', '*.svg')}`;
await promisify(exec)(command);
expect(await readFile(join('src', 'tests', 'results', 'nestedicons-cli.svg'), {
expect(await readFile(join('fixtures', 'results', 'nestedicons-cli.svg'), {
encoding: 'utf8',
})).toEqual(await readFile(join('src', 'tests', 'expected', 'nestedicons-cli.svg'), { encoding: 'utf8' }));
})).toEqual(await readFile(join('fixtures', 'expected', 'nestedicons-cli.svg'), {
encoding: 'utf8',
}));
});

@@ -64,0 +67,0 @@ });

import { describe, test, expect } from '@jest/globals';
import { fileSorter } from '../filesorter.js';
import { mkdir } from 'node:fs/promises';
import { join } from 'node:path';
try {
await mkdir(join('src', 'tests', 'results'));
}
catch (err) {
// empty
}
describe('fileSorter', () => {

@@ -12,0 +4,0 @@ test('should sort files per filename', () => {

@@ -12,3 +12,3 @@ import { describe, test, expect } from '@jest/globals';

try {
await mkdir(join('src', 'tests', 'results'));
await mkdir(join('fixtures', 'results'));
}

@@ -18,6 +18,6 @@ catch (err) {

}
const codepoint = JSON.parse(fs.readFileSync('./src/tests/expected/test-codepoint.json').toString());
const codepoint = JSON.parse(fs.readFileSync('./fixtures/expected/test-codepoint.json').toString());
// Helpers
async function generateFontToFile(options, fileSuffix, startUnicode, files) {
const dest = join('./src/tests', 'results', `${options.fontName + (fileSuffix || '')}.svg`);
const dest = join('fixtures', 'results', `${options.fontName + (fileSuffix || '')}.svg`);
let resolve;

@@ -34,3 +34,3 @@ let reject;

try {
expect(fs.readFileSync(dest, { encoding: 'utf8' })).toEqual(fs.readFileSync(join('./src/tests', 'expected', `${options.fontName + (fileSuffix || '')}.svg`), { encoding: 'utf8' }));
expect(fs.readFileSync(dest, { encoding: 'utf8' })).toEqual(fs.readFileSync(join('fixtures', 'expected', `${options.fontName + (fileSuffix || '')}.svg`), { encoding: 'utf8' }));
resolve();

@@ -42,3 +42,3 @@ }

});
new SVGIconsDirStream(files || join('src', 'tests', 'fixtures', options.fontName), {
new SVGIconsDirStream(files || join('fixtures', 'icons', options.fontName), {
startUnicode: startUnicode || 0xe001,

@@ -57,6 +57,8 @@ }).pipe(svgFontStream);

const promise = bufferStream(svgFontStream);
new SVGIconsDirStream(files || join('./src/tests', 'fixtures', options.fontName), {
new SVGIconsDirStream(files || join('fixtures', 'icons', options.fontName), {
startUnicode: startUnicode || 0xe001,
}).pipe(svgFontStream);
expect((await promise).toString()).toEqual(fs.readFileSync(join('./src/tests', 'expected', `${options.fontName}.svg`), { encoding: 'utf8' }));
expect((await promise).toString()).toEqual(fs.readFileSync(join('fixtures', 'expected', `${options.fontName}.svg`), {
encoding: 'utf8',
}));
}

@@ -213,36 +215,36 @@ // Tests

}, '', 0, [
'src/tests/fixtures/cleanicons/account.svg',
'src/tests/fixtures/cleanicons/arrow-down.svg',
'src/tests/fixtures/cleanicons/arrow-left.svg',
'src/tests/fixtures/cleanicons/arrow-right.svg',
'src/tests/fixtures/cleanicons/arrow-up.svg',
'src/tests/fixtures/cleanicons/basket.svg',
'src/tests/fixtures/cleanicons/close.svg',
'src/tests/fixtures/cleanicons/minus.svg',
'src/tests/fixtures/cleanicons/plus.svg',
'src/tests/fixtures/cleanicons/search.svg',
'src/tests/fixtures/hiddenpathesicons/sound--off.svg',
'src/tests/fixtures/hiddenpathesicons/sound--on.svg',
'src/tests/fixtures/multipathicons/kikoolol.svg',
'src/tests/fixtures/originalicons/mute.svg',
'src/tests/fixtures/originalicons/sound.svg',
'src/tests/fixtures/originalicons/speaker.svg',
'src/tests/fixtures/realicons/diegoliv.svg',
'src/tests/fixtures/realicons/hannesjohansson.svg',
'src/tests/fixtures/realicons/roelvanhitum.svg',
'src/tests/fixtures/realicons/safety-icon.svg',
'src/tests/fixtures/realicons/sb-icon.svg',
'src/tests/fixtures/realicons/settings-icon.svg',
'src/tests/fixtures/realicons/track-icon.svg',
'src/tests/fixtures/realicons/web-icon.svg',
'src/tests/fixtures/roundedcorners/roundedrect.svg',
'src/tests/fixtures/shapeicons/circle.svg',
'src/tests/fixtures/shapeicons/ellipse.svg',
'src/tests/fixtures/shapeicons/lines.svg',
'src/tests/fixtures/shapeicons/polygon.svg',
'src/tests/fixtures/shapeicons/polyline.svg',
'src/tests/fixtures/shapeicons/rect.svg',
'src/tests/fixtures/tocentericons/bottomleft.svg',
'src/tests/fixtures/tocentericons/center.svg',
'src/tests/fixtures/tocentericons/topright.svg',
'fixtures/icons/cleanicons/account.svg',
'fixtures/icons/cleanicons/arrow-down.svg',
'fixtures/icons/cleanicons/arrow-left.svg',
'fixtures/icons/cleanicons/arrow-right.svg',
'fixtures/icons/cleanicons/arrow-up.svg',
'fixtures/icons/cleanicons/basket.svg',
'fixtures/icons/cleanicons/close.svg',
'fixtures/icons/cleanicons/minus.svg',
'fixtures/icons/cleanicons/plus.svg',
'fixtures/icons/cleanicons/search.svg',
'fixtures/icons/hiddenpathesicons/sound--off.svg',
'fixtures/icons/hiddenpathesicons/sound--on.svg',
'fixtures/icons/multipathicons/kikoolol.svg',
'fixtures/icons/originalicons/mute.svg',
'fixtures/icons/originalicons/sound.svg',
'fixtures/icons/originalicons/speaker.svg',
'fixtures/icons/realicons/diegoliv.svg',
'fixtures/icons/realicons/hannesjohansson.svg',
'fixtures/icons/realicons/roelvanhitum.svg',
'fixtures/icons/realicons/safety-icon.svg',
'fixtures/icons/realicons/sb-icon.svg',
'fixtures/icons/realicons/settings-icon.svg',
'fixtures/icons/realicons/track-icon.svg',
'fixtures/icons/realicons/web-icon.svg',
'fixtures/icons/roundedcorners/roundedrect.svg',
'fixtures/icons/shapeicons/circle.svg',
'fixtures/icons/shapeicons/ellipse.svg',
'fixtures/icons/shapeicons/lines.svg',
'fixtures/icons/shapeicons/polygon.svg',
'fixtures/icons/shapeicons/polyline.svg',
'fixtures/icons/shapeicons/rect.svg',
'fixtures/icons/tocentericons/bottomleft.svg',
'fixtures/icons/tocentericons/center.svg',
'fixtures/icons/tocentericons/topright.svg',
]);

@@ -381,3 +383,3 @@ });

const svgFontStream = new SVGIcons2SVGFontStream({ round: 1e3 });
const svgIconStream = fs.createReadStream(join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'));
const svgIconStream = fs.createReadStream(join('fixtures', 'icons', 'cleanicons', 'account.svg'));
svgIconStream.metadata = {

@@ -390,3 +392,3 @@ name: 'account',

svgFontStream.end();
assert.equal(await promise, fs.readFileSync(join('./src/tests', 'expected', 'cleanicons-multi.svg'), {
assert.equal(await promise, fs.readFileSync(join('fixtures', 'expected', 'cleanicons-multi.svg'), {
encoding: 'utf8',

@@ -397,3 +399,3 @@ }));

const svgFontStream = new SVGIcons2SVGFontStream({ round: 1e3 });
const svgIconStream = fs.createReadStream(join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'));
const svgIconStream = fs.createReadStream(join('fixtures', 'icons', 'cleanicons', 'account.svg'));
svgIconStream.metadata = {

@@ -406,3 +408,3 @@ name: 'account',

svgFontStream.end();
assert.equal(await promise, fs.readFileSync(join('./src/tests', 'expected', 'cleanicons-lig.svg'), {
assert.equal(await promise, fs.readFileSync(join('fixtures', 'expected', 'cleanicons-lig.svg'), {
encoding: 'utf8',

@@ -413,3 +415,3 @@ }));

const svgFontStream = new SVGIcons2SVGFontStream({ round: 1e3 });
const svgIconStream = fs.createReadStream(join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'));
const svgIconStream = fs.createReadStream(join('fixtures', 'icons', 'cleanicons', 'account.svg'));
svgIconStream.metadata = {

@@ -422,3 +424,3 @@ name: 'account',

svgFontStream.end();
assert.equal((await promise).toString(), fs.readFileSync(join('src/tests', 'expected', 'cleanicons-high.svg'), {
assert.equal((await promise).toString(), fs.readFileSync(join('fixtures', 'expected', 'cleanicons-high.svg'), {
encoding: 'utf8',

@@ -430,3 +432,3 @@ }));

test('should fail when not providing glyph name', async () => {
const svgIconStream = fs.createReadStream(join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'));
const svgIconStream = fs.createReadStream(join('fixtures', 'icons', 'cleanicons', 'account.svg'));
svgIconStream.metadata = {

@@ -444,3 +446,3 @@ name: undefined,

test('should fail when not providing codepoints', async () => {
const svgIconStream = fs.createReadStream(join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'));
const svgIconStream = fs.createReadStream(join('fixtures', 'icons', 'cleanicons', 'account.svg'));
svgIconStream.metadata = {

@@ -458,3 +460,3 @@ name: 'test',

test('should fail when providing unicode value with duplicates', async () => {
const svgIconStream = fs.createReadStream(join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'));
const svgIconStream = fs.createReadStream(join('fixtures', 'icons', 'cleanicons', 'account.svg'));
svgIconStream.metadata = {

@@ -472,4 +474,4 @@ name: 'test',

test('should fail when providing the same codepoint twice', async () => {
const svgIconStream = fs.createReadStream(join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'));
const svgIconStream2 = fs.createReadStream(join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'));
const svgIconStream = fs.createReadStream(join('fixtures', 'icons', 'cleanicons', 'account.svg'));
const svgIconStream2 = fs.createReadStream(join('fixtures', 'icons', 'cleanicons', 'account.svg'));
const svgFontStream = new SVGIcons2SVGFontStream({

@@ -494,4 +496,4 @@ round: 1e3,

test('should fail when providing the same name twice', async () => {
const svgIconStream = fs.createReadStream(join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'));
const svgIconStream2 = fs.createReadStream(join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'));
const svgIconStream = fs.createReadStream(join('fixtures', 'icons', 'cleanicons', 'account.svg'));
const svgIconStream2 = fs.createReadStream(join('fixtures', 'icons', 'cleanicons', 'account.svg'));
const svgFontStream = new SVGIcons2SVGFontStream({ round: 1e3 });

@@ -514,3 +516,3 @@ svgIconStream.metadata = {

test('should fail when providing bad pathdata', async () => {
const svgIconStream = fs.createReadStream(join('./src/tests', 'fixtures', 'badicons', 'pathdata.svg'));
const svgIconStream = fs.createReadStream(join('fixtures', 'icons', 'badicons', 'pathdata.svg'));
svgIconStream.metadata = {

@@ -517,0 +519,0 @@ name: 'test',

@@ -30,6 +30,6 @@ import { describe, test, expect } from '@jest/globals';

});
await writeFile(join('.', 'src', 'tests', 'results', 'plop.svg'), 'plop', 'utf-8');
const infos = await promisify(metadataService)(join('.', 'src', 'tests', 'results', 'plop.svg'));
await writeFile(join('fixtures', 'results', 'plop.svg'), 'plop', 'utf-8');
const infos = await promisify(metadataService)(join('fixtures', 'results', 'plop.svg'));
expect(infos).toEqual({
path: join('.', 'src', 'tests', 'results', 'uEA01-plop.svg'),
path: join('fixtures', 'results', 'uEA01-plop.svg'),
name: 'plop',

@@ -39,6 +39,6 @@ unicode: [String.fromCharCode(0xea01)],

});
expect(await readFile(join('.', 'src', 'tests', 'results', 'uEA01-plop.svg'))).toBeTruthy();
unlink(join('.', 'src', 'tests', 'results', 'uEA01-plop.svg'));
expect(await readFile(join('fixtures', 'results', 'uEA01-plop.svg'))).toBeTruthy();
unlink(join('fixtures', 'results', 'uEA01-plop.svg'));
try {
await readFile(join('.', 'src', 'tests', 'results', 'plop.svg'));
await readFile(join('fixtures', 'results', 'plop.svg'));
throw new YError('E_UNEXPECTED_SUCCESS');

@@ -56,3 +56,3 @@ }

try {
await promisify(metadataService)(join('.', 'src', 'tests', 'results', 'plop.svg'));
await promisify(metadataService)(join('fixtures', 'results', 'plop.svg'));
throw new YError('E_UNEXPECTED_SUCCESS');

@@ -65,3 +65,3 @@ }

try {
await readFile(join('.', 'src', 'tests', 'results', 'uEA02-plop.svg'));
await readFile(join('fixtures', 'results', 'uEA02-plop.svg'));
throw new YError('E_UNEXPECTED_SUCCESS');

@@ -68,0 +68,0 @@ }

@@ -18,7 +18,8 @@ {

"dist",
"src/tests/results"
"fixtures/results"
],
"bundleFiles": [
"dist",
"src"
"src",
"bin"
]

@@ -28,3 +29,3 @@ }

"name": "svgicons2svgfont",
"version": "14.0.0",
"version": "14.0.1",
"description": "Read a set of SVG icons and output a SVG font",

@@ -70,6 +71,6 @@ "homepage": "https://github.com/nfroidure/svgicons2svgfont",

"commander": "^12.1.0",
"debug": "^4.3.6",
"glob": "^11.0.0",
"sax": "^1.4.1",
"svg-pathdata": "^7.0.0",
"transformation-matrix": "^2.16.1",
"transformation-matrix-js": "^2.7.6",

@@ -128,2 +129,3 @@ "yerror": "^8.0.0"

"src",
"bin",
"LICENSE",

@@ -130,0 +132,0 @@ "README.md",

@@ -79,2 +79,6 @@ [//]: # ( )

## Debugging
To debug, simply use the following env var: `DEBUG=svgicons2svgfont`.
## CLI interface

@@ -81,0 +85,0 @@

@@ -9,3 +9,6 @@ import { Readable } from 'node:stream';

} from './metadata.js';
import debug from 'debug';
const warn = debug('svgicons2svgfont');
export type SVGIconsDirStreamOptions = {

@@ -56,3 +59,3 @@ metadataProvider: ReturnType<typeof getMetadataService>;

if (metadata.renamed) {
console.log(
warn(
'➕ - Saved codepoint: ' +

@@ -59,0 +62,0 @@ 'u' +

@@ -8,3 +8,6 @@ import { ucs2 } from 'punycode';

import { YError } from 'yerror';
import debug from 'debug';
const warn = debug('svgicons2svgfont');
export { fileSorter } from './filesorter.js';

@@ -299,4 +302,4 @@ export * from './iconsdir.js';

} else {
console.log(
`Glyph "${glyph.name}" has no width attribute, using current glyph horizontal bounds.`,
warn(
`⚠️ - Glyph "${glyph.name}" has no width attribute, using current glyph horizontal bounds.`,
);

@@ -308,4 +311,4 @@ glyph.defaultWidth = true;

} else {
console.log(
`Glyph "${glyph.name}" has no height attribute, using current glyph vertical bounds.`,
warn(
`⚠️ - Glyph "${glyph.name}" has no height attribute, using current glyph vertical bounds.`,
);

@@ -317,4 +320,4 @@ glyph.defaultHeight = true;

// Clipping path unsupported
console.log(
`Found a clipPath element in the icon "${glyph.name}" the result may be different than expected.`,
warn(
`🤷 - Found a clipPath element in the icon "${glyph.name}" the result may be different than expected.`,
);

@@ -326,4 +329,4 @@ } else if ('rect' === tag.name && 'none' !== tag.attributes.fill) {

} else if ('line' === tag.name && 'none' !== tag.attributes.fill) {
console.log(
`Found a line element in the icon "${glyph.name}" the result could be different than expected.`,
warn(
`🤷 - Found a line element in the icon "${glyph.name}" the result could be different than expected.`,
);

@@ -334,4 +337,4 @@ glyph.paths.push(

} else if ('polyline' === tag.name && 'none' !== tag.attributes.fill) {
console.log(
`Found a polyline element in the icon "${glyph.name}" the result could be different than expected.`,
warn(
`🤷 - Found a polyline element in the icon "${glyph.name}" the result could be different than expected.`,
);

@@ -453,4 +456,4 @@ glyph.paths.push(

) {
console.log(
'The provided icons do not have the same heights. This could lead' +
warn(
'🤷 - The provided icons do not have the same heights. This could lead' +
' to unexpected results. Using the normalize option may help.',

@@ -460,4 +463,4 @@ );

if (1000 > fontHeight) {
console.log(
'A fontHeight of at least than 1000 is recommended, otherwise ' +
warn(
'🤷 - A fontHeight of at least than 1000 is recommended, otherwise ' +
'further steps (rounding in svg2ttf) could lead to ugly results.' +

@@ -592,3 +595,3 @@ ' Use the fontHeight option to scale icons.',

this.push(' </font>\n' + '</defs>\n' + '</svg>\n');
console.log('Font created');
warn('✅ - Font created');
if ('function' === typeof this._options.callback) {

@@ -595,0 +598,0 @@ this._options.callback(this.glyphs);

@@ -8,3 +8,3 @@ import { describe, test, expect } from '@jest/globals';

try {
await mkdir(join('src', 'tests', 'results'));
await mkdir(join('fixtures', 'results'));
} catch (err) {

@@ -18,8 +18,6 @@ // empty

`${'node' + ' '}${join('bin', 'svgicons2svgfont.js')} -o ${join(
'src',
'tests',
'fixtures',
'results',
'originalicons-cli.svg',
)} -s 0xE001` +
` ${join('src', 'tests', 'fixtures', 'originalicons', '*.svg')}`;
)} -s 0xE001` + ` ${join('fixtures', 'icons', 'originalicons', '*.svg')}`;

@@ -29,10 +27,9 @@ await promisify(exec)(command);

expect(
await readFile(join('src', 'tests', 'results', 'originalicons-cli.svg'), {
await readFile(join('fixtures', 'results', 'originalicons-cli.svg'), {
encoding: 'utf8',
}),
).toEqual(
await readFile(
join('src', 'tests', 'expected', 'originalicons-cli.svg'),
{ encoding: 'utf8' },
),
await readFile(join('fixtures', 'expected', 'originalicons-cli.svg'), {
encoding: 'utf8',
}),
);

@@ -47,21 +44,21 @@ });

' -o ' +
join('src', 'tests', 'results', 'lotoficons-cli.svg') +
join('fixtures', 'results', 'lotoficons-cli.svg') +
' -s 0xE001' +
' -r 1e4' +
' ' +
join('src', 'tests', 'fixtures', 'cleanicons', '*.svg') +
join('fixtures', 'icons', 'cleanicons', '*.svg') +
' ' +
join('src', 'tests', 'fixtures', 'hiddenpathesicons', '*.svg') +
join('fixtures', 'icons', 'hiddenpathesicons', '*.svg') +
' ' +
join('src', 'tests', 'fixtures', 'multipathicons', 'kikoolol.svg') +
join('fixtures', 'icons', 'multipathicons', 'kikoolol.svg') +
' ' +
join('src', 'tests', 'fixtures', 'originalicons', '*.svg') +
join('fixtures', 'icons', 'originalicons', '*.svg') +
' ' +
join('src', 'tests', 'fixtures', 'realicons', '*.svg') +
join('fixtures', 'icons', 'realicons', '*.svg') +
' ' +
join('src', 'tests', 'fixtures', 'roundedcorners', '*.svg') +
join('fixtures', 'icons', 'roundedcorners', '*.svg') +
' ' +
join('src', 'tests', 'fixtures', 'shapeicons', '*.svg') +
join('fixtures', 'icons', 'shapeicons', '*.svg') +
' ' +
join('src', 'tests', 'fixtures', 'tocentericons', '*.svg');
join('fixtures', 'icons', 'tocentericons', '*.svg');

@@ -71,7 +68,7 @@ await promisify(exec)(command);

expect(
await readFile(join('src', 'tests', 'results', 'lotoficons-cli.svg'), {
await readFile(join('fixtures', 'results', 'lotoficons-cli.svg'), {
encoding: 'utf8',
}),
).toEqual(
await readFile(join('src', 'tests', 'expected', 'lotoficons-cli.svg'), {
await readFile(join('fixtures', 'expected', 'lotoficons-cli.svg'), {
encoding: 'utf8',

@@ -88,7 +85,6 @@ }),

)} -o ${join(
'src',
'tests',
'fixtures',
'results',
'nestedicons-cli.svg',
)} ${join('src', 'tests', 'fixtures', 'nestedicons', '*.svg')}`;
)} ${join('fixtures', 'icons', 'nestedicons', '*.svg')}`;

@@ -98,10 +94,9 @@ await promisify(exec)(command);

expect(
await readFile(join('src', 'tests', 'results', 'nestedicons-cli.svg'), {
await readFile(join('fixtures', 'results', 'nestedicons-cli.svg'), {
encoding: 'utf8',
}),
).toEqual(
await readFile(
join('src', 'tests', 'expected', 'nestedicons-cli.svg'),
{ encoding: 'utf8' },
),
await readFile(join('fixtures', 'expected', 'nestedicons-cli.svg'), {
encoding: 'utf8',
}),
);

@@ -108,0 +103,0 @@ });

import { describe, test, expect } from '@jest/globals';
import { fileSorter } from '../filesorter.js';
import { mkdir } from 'node:fs/promises';
import { join } from 'node:path';
try {
await mkdir(join('src', 'tests', 'results'));
} catch (err) {
// empty
}
describe('fileSorter', () => {

@@ -13,0 +5,0 @@ test('should sort files per filename', () => {

@@ -15,3 +15,3 @@ import { describe, test, expect } from '@jest/globals';

try {
await mkdir(join('src', 'tests', 'results'));
await mkdir(join('fixtures', 'results'));
} catch (err) {

@@ -22,3 +22,3 @@ // empty

const codepoint = JSON.parse(
fs.readFileSync('./src/tests/expected/test-codepoint.json').toString(),
fs.readFileSync('./fixtures/expected/test-codepoint.json').toString(),
);

@@ -29,3 +29,3 @@

const dest = join(
'./src/tests',
'fixtures',
'results',

@@ -51,3 +51,3 @@ `${options.fontName + (fileSuffix || '')}.svg`,

join(
'./src/tests',
'fixtures',
'expected',

@@ -65,8 +65,5 @@ `${options.fontName + (fileSuffix || '')}.svg`,

new SVGIconsDirStream(
files || join('src', 'tests', 'fixtures', options.fontName),
{
startUnicode: startUnicode || 0xe001,
},
).pipe(svgFontStream);
new SVGIconsDirStream(files || join('fixtures', 'icons', options.fontName), {
startUnicode: startUnicode || 0xe001,
}).pipe(svgFontStream);

@@ -89,14 +86,10 @@ return await promise;

new SVGIconsDirStream(
files || join('./src/tests', 'fixtures', options.fontName),
{
startUnicode: startUnicode || 0xe001,
},
).pipe(svgFontStream);
new SVGIconsDirStream(files || join('fixtures', 'icons', options.fontName), {
startUnicode: startUnicode || 0xe001,
}).pipe(svgFontStream);
expect((await promise).toString()).toEqual(
fs.readFileSync(
join('./src/tests', 'expected', `${options.fontName}.svg`),
{ encoding: 'utf8' },
),
fs.readFileSync(join('fixtures', 'expected', `${options.fontName}.svg`), {
encoding: 'utf8',
}),
);

@@ -305,36 +298,36 @@ }

[
'src/tests/fixtures/cleanicons/account.svg',
'src/tests/fixtures/cleanicons/arrow-down.svg',
'src/tests/fixtures/cleanicons/arrow-left.svg',
'src/tests/fixtures/cleanicons/arrow-right.svg',
'src/tests/fixtures/cleanicons/arrow-up.svg',
'src/tests/fixtures/cleanicons/basket.svg',
'src/tests/fixtures/cleanicons/close.svg',
'src/tests/fixtures/cleanicons/minus.svg',
'src/tests/fixtures/cleanicons/plus.svg',
'src/tests/fixtures/cleanicons/search.svg',
'src/tests/fixtures/hiddenpathesicons/sound--off.svg',
'src/tests/fixtures/hiddenpathesicons/sound--on.svg',
'src/tests/fixtures/multipathicons/kikoolol.svg',
'src/tests/fixtures/originalicons/mute.svg',
'src/tests/fixtures/originalicons/sound.svg',
'src/tests/fixtures/originalicons/speaker.svg',
'src/tests/fixtures/realicons/diegoliv.svg',
'src/tests/fixtures/realicons/hannesjohansson.svg',
'src/tests/fixtures/realicons/roelvanhitum.svg',
'src/tests/fixtures/realicons/safety-icon.svg',
'src/tests/fixtures/realicons/sb-icon.svg',
'src/tests/fixtures/realicons/settings-icon.svg',
'src/tests/fixtures/realicons/track-icon.svg',
'src/tests/fixtures/realicons/web-icon.svg',
'src/tests/fixtures/roundedcorners/roundedrect.svg',
'src/tests/fixtures/shapeicons/circle.svg',
'src/tests/fixtures/shapeicons/ellipse.svg',
'src/tests/fixtures/shapeicons/lines.svg',
'src/tests/fixtures/shapeicons/polygon.svg',
'src/tests/fixtures/shapeicons/polyline.svg',
'src/tests/fixtures/shapeicons/rect.svg',
'src/tests/fixtures/tocentericons/bottomleft.svg',
'src/tests/fixtures/tocentericons/center.svg',
'src/tests/fixtures/tocentericons/topright.svg',
'fixtures/icons/cleanicons/account.svg',
'fixtures/icons/cleanicons/arrow-down.svg',
'fixtures/icons/cleanicons/arrow-left.svg',
'fixtures/icons/cleanicons/arrow-right.svg',
'fixtures/icons/cleanicons/arrow-up.svg',
'fixtures/icons/cleanicons/basket.svg',
'fixtures/icons/cleanicons/close.svg',
'fixtures/icons/cleanicons/minus.svg',
'fixtures/icons/cleanicons/plus.svg',
'fixtures/icons/cleanicons/search.svg',
'fixtures/icons/hiddenpathesicons/sound--off.svg',
'fixtures/icons/hiddenpathesicons/sound--on.svg',
'fixtures/icons/multipathicons/kikoolol.svg',
'fixtures/icons/originalicons/mute.svg',
'fixtures/icons/originalicons/sound.svg',
'fixtures/icons/originalicons/speaker.svg',
'fixtures/icons/realicons/diegoliv.svg',
'fixtures/icons/realicons/hannesjohansson.svg',
'fixtures/icons/realicons/roelvanhitum.svg',
'fixtures/icons/realicons/safety-icon.svg',
'fixtures/icons/realicons/sb-icon.svg',
'fixtures/icons/realicons/settings-icon.svg',
'fixtures/icons/realicons/track-icon.svg',
'fixtures/icons/realicons/web-icon.svg',
'fixtures/icons/roundedcorners/roundedrect.svg',
'fixtures/icons/shapeicons/circle.svg',
'fixtures/icons/shapeicons/ellipse.svg',
'fixtures/icons/shapeicons/lines.svg',
'fixtures/icons/shapeicons/polygon.svg',
'fixtures/icons/shapeicons/polyline.svg',
'fixtures/icons/shapeicons/rect.svg',
'fixtures/icons/tocentericons/bottomleft.svg',
'fixtures/icons/tocentericons/center.svg',
'fixtures/icons/tocentericons/topright.svg',
],

@@ -531,3 +524,3 @@ );

const svgIconStream = fs.createReadStream(
join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'),
join('fixtures', 'icons', 'cleanicons', 'account.svg'),
) as unknown as SVGIconStream;

@@ -547,3 +540,3 @@

await promise,
fs.readFileSync(join('./src/tests', 'expected', 'cleanicons-multi.svg'), {
fs.readFileSync(join('fixtures', 'expected', 'cleanicons-multi.svg'), {
encoding: 'utf8',

@@ -557,3 +550,3 @@ }),

const svgIconStream = fs.createReadStream(
join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'),
join('fixtures', 'icons', 'cleanicons', 'account.svg'),
) as unknown as SVGIconStream;

@@ -572,3 +565,3 @@

await promise,
fs.readFileSync(join('./src/tests', 'expected', 'cleanicons-lig.svg'), {
fs.readFileSync(join('fixtures', 'expected', 'cleanicons-lig.svg'), {
encoding: 'utf8',

@@ -582,3 +575,3 @@ }),

const svgIconStream = fs.createReadStream(
join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'),
join('fixtures', 'icons', 'cleanicons', 'account.svg'),
) as unknown as SVGIconStream;

@@ -598,3 +591,3 @@

(await promise).toString(),
fs.readFileSync(join('src/tests', 'expected', 'cleanicons-high.svg'), {
fs.readFileSync(join('fixtures', 'expected', 'cleanicons-high.svg'), {
encoding: 'utf8',

@@ -609,3 +602,3 @@ }),

const svgIconStream = fs.createReadStream(
join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'),
join('fixtures', 'icons', 'cleanicons', 'account.svg'),
) as unknown as SVGIconStream;

@@ -630,3 +623,3 @@

const svgIconStream = fs.createReadStream(
join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'),
join('fixtures', 'icons', 'cleanicons', 'account.svg'),
) as unknown as SVGIconStream;

@@ -651,3 +644,3 @@

const svgIconStream = fs.createReadStream(
join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'),
join('fixtures', 'icons', 'cleanicons', 'account.svg'),
) as unknown as SVGIconStream;

@@ -672,6 +665,6 @@

const svgIconStream = fs.createReadStream(
join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'),
join('fixtures', 'icons', 'cleanicons', 'account.svg'),
) as unknown as SVGIconStream;
const svgIconStream2 = fs.createReadStream(
join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'),
join('fixtures', 'icons', 'cleanicons', 'account.svg'),
) as unknown as SVGIconStream;

@@ -703,6 +696,6 @@ const svgFontStream = new SVGIcons2SVGFontStream({

const svgIconStream = fs.createReadStream(
join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'),
join('fixtures', 'icons', 'cleanicons', 'account.svg'),
) as unknown as SVGIconStream;
const svgIconStream2 = fs.createReadStream(
join('./src/tests', 'fixtures', 'cleanicons', 'account.svg'),
join('fixtures', 'icons', 'cleanicons', 'account.svg'),
) as unknown as SVGIconStream;

@@ -729,3 +722,3 @@ const svgFontStream = new SVGIcons2SVGFontStream({ round: 1e3 });

const svgIconStream = fs.createReadStream(
join('./src/tests', 'fixtures', 'badicons', 'pathdata.svg'),
join('fixtures', 'icons', 'badicons', 'pathdata.svg'),
) as unknown as SVGIconStream;

@@ -732,0 +725,0 @@

@@ -35,3 +35,3 @@ import { describe, test, expect } from '@jest/globals';

await writeFile(
join('.', 'src', 'tests', 'results', 'plop.svg'),
join('fixtures', 'results', 'plop.svg'),
'plop',

@@ -41,7 +41,7 @@ 'utf-8',

const infos = await promisify(metadataService)(
join('.', 'src', 'tests', 'results', 'plop.svg'),
join('fixtures', 'results', 'plop.svg'),
);
expect(infos).toEqual({
path: join('.', 'src', 'tests', 'results', 'uEA01-plop.svg'),
path: join('fixtures', 'results', 'uEA01-plop.svg'),
name: 'plop',

@@ -52,7 +52,7 @@ unicode: [String.fromCharCode(0xea01)],

expect(
await readFile(join('.', 'src', 'tests', 'results', 'uEA01-plop.svg')),
await readFile(join('fixtures', 'results', 'uEA01-plop.svg')),
).toBeTruthy();
unlink(join('.', 'src', 'tests', 'results', 'uEA01-plop.svg'));
unlink(join('fixtures', 'results', 'uEA01-plop.svg'));
try {
await readFile(join('.', 'src', 'tests', 'results', 'plop.svg'));
await readFile(join('fixtures', 'results', 'plop.svg'));
throw new YError('E_UNEXPECTED_SUCCESS');

@@ -72,3 +72,3 @@ } catch (err) {

await promisify(metadataService)(
join('.', 'src', 'tests', 'results', 'plop.svg'),
join('fixtures', 'results', 'plop.svg'),
);

@@ -82,3 +82,3 @@

try {
await readFile(join('.', 'src', 'tests', 'results', 'uEA02-plop.svg'));
await readFile(join('fixtures', 'results', 'uEA02-plop.svg'));
throw new YError('E_UNEXPECTED_SUCCESS');

@@ -85,0 +85,0 @@ } catch (err) {

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

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